mirror of
https://github.com/discourse/discourse.git
synced 2024-12-18 15:43:47 +08:00
eff6e4b405
Float-kit elements (menus/tooltips) are positioned where they should be by setting an inline `left` property in JavaScript when they're rendered. For some reasons, we also set `left: 0` on float-kit elements here:
25d9927785/app/assets/stylesheets/common/float-kit/d-menu.scss (L11-L15)
This property is overridden by the inline property that the library sets in JavaScript. However, in RTL mode, all of our scss files are flipped where everything left becomes right and vice versa. In this case, the `left: 0` property in the scss file above becomes `right: 0`.
This results in a conflict specific to RTL mode where both the `left` and `right` properties are defined on the same absolute-positioned element; the `right` property will always be set to 0 because it comes from the (flipped) scss file above, and the inline `left` property will be set to some px amount determined in JavaScript.
The `right` property will take precedence over the inline `left` property due to the page being right-to-left (source: https://developer.mozilla.org/en-US/docs/Web/CSS/right#description) and this causes float-kit elements to incorrectly always stick to the right.
This commit removes the `left: 0` property altogether for float-kit elements from our scss files. It's not clear from git history why the property was added, and removing it doesn't seem to cause any issues.
Meta topic: https://meta.discourse.org/t/positioning-issues-with-rtl-locales-after-recent-updates/280220?u=osama
91 lines
1.4 KiB
SCSS
91 lines
1.4 KiB
SCSS
@keyframes d-menu-opening {
|
|
0% {
|
|
opacity: 0;
|
|
}
|
|
|
|
100% {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
.fk-d-menu {
|
|
width: max-content;
|
|
position: absolute;
|
|
top: 0;
|
|
max-width: 600px;
|
|
display: flex;
|
|
padding: 0;
|
|
z-index: z("dropdown");
|
|
|
|
&__trigger {
|
|
.touch & {
|
|
@include unselectable;
|
|
}
|
|
}
|
|
|
|
&.-animated {
|
|
animation: d-menu-opening 0.15s ease-in;
|
|
|
|
&[data-placement^="bottom"] {
|
|
transform-origin: top center;
|
|
}
|
|
|
|
&[data-placement^="top"] {
|
|
transform-origin: bottom center;
|
|
}
|
|
|
|
&[data-placement^="right"] {
|
|
transform-origin: center left;
|
|
}
|
|
|
|
&[data-placement^="left"] {
|
|
transform-origin: center right;
|
|
}
|
|
}
|
|
|
|
&[data-strategy="fixed"] {
|
|
position: fixed;
|
|
}
|
|
|
|
&__inner-content {
|
|
display: flex;
|
|
border-radius: var(--d-border-radius);
|
|
background-color: var(--secondary);
|
|
border: 1px solid var(--primary-low);
|
|
box-shadow: var(--shadow-menu-panel);
|
|
}
|
|
|
|
.arrow {
|
|
z-index: z("max");
|
|
position: absolute;
|
|
color: var(--secondary);
|
|
}
|
|
|
|
&[data-placement^="top"] {
|
|
.arrow {
|
|
bottom: -9px;
|
|
rotate: 180deg;
|
|
}
|
|
}
|
|
|
|
&[data-placement^="bottom"] {
|
|
.arrow {
|
|
top: -9px;
|
|
}
|
|
}
|
|
|
|
&[data-placement^="right"] {
|
|
.arrow {
|
|
rotate: -90deg;
|
|
left: -9px;
|
|
}
|
|
}
|
|
|
|
&[data-placement^="left"] {
|
|
.arrow {
|
|
rotate: 90deg;
|
|
right: -9px;
|
|
}
|
|
}
|
|
}
|