Skip to content

Commit

Permalink
FIX: sk3 wizard regressions (#14120)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaffeux committed Aug 23, 2021
1 parent 3d6cbb5 commit a230362
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default Component.extend(
this.set(
"selectKit",
EmberObject.create({
uniqueID: this.attrs?.id || guidFor(this),
uniqueID: this.attrs?.id?.value || this.attrs?.id || guidFor(this),
valueProperty: this.valueProperty,
nameProperty: this.nameProperty,
labelProperty: this.labelProperty,
Expand Down Expand Up @@ -838,7 +838,7 @@ export default Component.extend(
this.clearErrors();

const inModal = this.element.closest("#discourse-modal");
if (inModal && this.site.mobileView) {
if (inModal && this?.site?.mobileView) {
const modalBody = inModal.querySelector(".modal-body");
modalBody.style = "";
}
Expand Down Expand Up @@ -870,7 +870,7 @@ export default Component.extend(
`#${this.selectKit.uniqueID}-body`
);

const placementStrategy = this.site.mobileView ? "absolute" : "fixed";
const placementStrategy = this?.site?.mobileView ? "absolute" : "fixed";
const verticalOffset = 3;

this.popper = createPopper(anchor, popper, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { propertyEqual } from "discourse/lib/computed";
import { action, computed } from "@ember/object";
import Component from "@ember/component";
import I18n from "I18n";
Expand Down Expand Up @@ -36,7 +35,7 @@ export default Component.extend(UtilsMixin, {
didInsertElement() {
this._super(...arguments);

if (!this.site.mobileView) {
if (!this?.site?.mobileView) {
this.element.addEventListener("mouseenter", this.handleMouseEnter);
this.element.addEventListener("focus", this.handleMouseEnter);
this.element.addEventListener("blur", this.handleBlur);
Expand All @@ -45,7 +44,7 @@ export default Component.extend(UtilsMixin, {

willDestroyElement() {
this._super(...arguments);
if (!this.site.mobileView && this.element) {
if (!this?.site?.mobileView && this.element) {
this.element.removeEventListener("mouseenter", this.handleBlur);
this.element.removeEventListener("focus", this.handleMouseEnter);
this.element.removeEventListener("blur", this.handleMouseEnter);
Expand Down Expand Up @@ -115,9 +114,13 @@ export default Component.extend(UtilsMixin, {
return this.getValue(this.selectKit.highlighted);
}),

isHighlighted: propertyEqual("rowValue", "highlightedValue"),
isHighlighted: computed("rowValue", "highlightedValue", function () {
return this.rowValue === this.highlightedValue;
}),

isSelected: propertyEqual("rowValue", "value"),
isSelected: computed("rowValue", "value", function () {
return this.rowValue === this.value;
}),

@action
handleMouseEnter() {
Expand Down
7 changes: 5 additions & 2 deletions app/assets/stylesheets/common/select-kit/select-kit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@
overflow: hidden;
transition: all 0.25s;
cursor: pointer;
display: flex;
align-items: stretch;

.select-kit-header-wrapper {
box-sizing: border-box;
min-height: 28px;
display: flex;
align-items: center;
flex: 1 0 auto;
width: 100%;
align-items: center;
height: 100%;
}

Expand Down Expand Up @@ -262,6 +263,8 @@
border-radius: 0;
box-shadow: none;
width: 100%;
box-sizing: border-box;
min-height: 30px;
}

&.is-hidden {
Expand Down

0 comments on commit a230362

Please sign in to comment.