[FIX] Improves select positioning with direction=rtl in a modal

This commit is contained in:
Joffrey JAFFEUX 2017-10-20 07:01:04 -07:00 committed by GitHub
parent 21af7d7755
commit 671af2690e
1 changed files with 21 additions and 20 deletions

View File

@ -407,35 +407,35 @@ export default Ember.Component.extend(UtilsMixin, DomHelpersMixin, KeyboardMixin
const width = this.$().outerWidth(false); const width = this.$().outerWidth(false);
const height = this.$header().outerHeight(false); const height = this.$header().outerHeight(false);
if (this.get("scrollableParent").length === 0) { if (this.get("scrollableParent").length === 0) { return; }
return;
}
const $placeholder = $(`<div class='select-box-kit-fixed-placeholder-${this.elementId}'></div>`); const $placeholder = $(`<div class='select-box-kit-fixed-placeholder-${this.elementId}'></div>`);
this._previousScrollParentOverflow = this.get("scrollableParent").css("overflow"); this._previousScrollParentOverflow = this.get("scrollableParent").css("overflow");
this.get("scrollableParent").css({ overflow: "hidden" });
this._previousCSSContext = { this._previousCSSContext = {
minWidth: this.$().css("min-width"), minWidth: this.$().css("min-width"),
maxWidth: this.$().css("max-width") maxWidth: this.$().css("max-width")
}; };
this.get("scrollableParent").css({ overflow: "hidden" });
this.$() const componentStyles = {
.before($placeholder.css({
display: "inline-block",
width,
height,
"vertical-align": "middle"
}))
.css({
direction: $("html").css("direction"),
position: "fixed", position: "fixed",
"margin-top": -this.get("scrollableParent").scrollTop(), "margin-top": -this.get("scrollableParent").scrollTop(),
"margin-left": -width,
width, width,
minWidth: "unset", minWidth: "unset",
maxWidth: "unset" maxWidth: "unset"
}); };
if ($("html").css("direction") === "rtl") {
componentStyles.marginRight = -width;
} else {
componentStyles.marginLeft = -width;
}
$placeholder.css({ display: "inline-block", width, height, "vertical-align": "middle" });
this.$().before($placeholder).css(componentStyles);
}, },
_removeFixedPosition() { _removeFixedPosition() {
@ -451,6 +451,7 @@ export default Ember.Component.extend(UtilsMixin, DomHelpersMixin, KeyboardMixin
top: "auto", top: "auto",
left: "auto", left: "auto",
"margin-left": "auto", "margin-left": "auto",
"margin-right": "auto",
"margin-top": "auto", "margin-top": "auto",
position: "relative" position: "relative"
} }