mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 04:28:29 -05:00
FIX: multiple select-kit fixes on mobile
This commit is contained in:
@@ -22,7 +22,7 @@ export default ComboBox.extend(Tags, {
|
||||
fullWidthOnMobile: true,
|
||||
|
||||
init() {
|
||||
this._super();
|
||||
this._super(...arguments);
|
||||
|
||||
this.set("termMatchesForbidden", false);
|
||||
this.selectionSelector = ".selected-tag";
|
||||
@@ -45,6 +45,27 @@ export default ComboBox.extend(Tags, {
|
||||
);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
$(".selected-name").off("touchend.select-kit pointerup.select-kit");
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
$(".selected-name").on(
|
||||
"touchend.select-kit pointerup.select-kit",
|
||||
event => {
|
||||
if (!this.get("isExpanded")) {
|
||||
this.expand(event);
|
||||
}
|
||||
|
||||
this.focusFilterOrHeader();
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
@computed("hasReachedMaximum")
|
||||
caretIcon(hasReachedMaximum) {
|
||||
return hasReachedMaximum ? null : "plus fa-fw";
|
||||
|
||||
@@ -92,17 +92,6 @@ export default Ember.Component.extend(
|
||||
this.set("computedContent", []);
|
||||
this.set("highlightedSelection", []);
|
||||
|
||||
if (this.site && this.site.isMobileDevice) {
|
||||
this.setProperties({
|
||||
filterable: isNone(this.get("filterable"))
|
||||
? false
|
||||
: this.get("filterable"),
|
||||
autoFilterable: isNone(this.get("autoFilterable"))
|
||||
? false
|
||||
: this.get("filterable")
|
||||
});
|
||||
}
|
||||
|
||||
if (this.get("nameChanges")) {
|
||||
this.addObserver(
|
||||
`content.@each.${this.get("nameProperty")}`,
|
||||
@@ -458,7 +447,7 @@ export default Ember.Component.extend(
|
||||
|
||||
clearSelection() {
|
||||
this.deselect(this.get("selection"));
|
||||
this.focus();
|
||||
this.focusFilterOrHeader();
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
@@ -82,9 +82,7 @@ export default Ember.Mixin.create({
|
||||
},
|
||||
|
||||
focus() {
|
||||
Ember.run.schedule("afterRender", () => {
|
||||
this.$header().focus();
|
||||
});
|
||||
this.focusFilterOrHeader();
|
||||
},
|
||||
|
||||
// try to focus filter and fallback to header if not present
|
||||
@@ -93,12 +91,12 @@ export default Ember.Mixin.create({
|
||||
// next so we are sure it finised expand/collapse
|
||||
Ember.run.next(() => {
|
||||
Ember.run.schedule("afterRender", () => {
|
||||
if (
|
||||
(this.site && this.site.isMobileDevice) ||
|
||||
!context.$filterInput() ||
|
||||
!context.$filterInput().is(":visible")
|
||||
) {
|
||||
context.$header().focus();
|
||||
if (!context.$filterInput() || !context.$filterInput().is(":visible")) {
|
||||
if (context.$header()) {
|
||||
context.$header().focus();
|
||||
} else {
|
||||
$(context.element).focus();
|
||||
}
|
||||
} else {
|
||||
context.$filterInput().focus();
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ export default Ember.Mixin.create({
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super();
|
||||
this._super(...arguments);
|
||||
|
||||
$(document).off("mousedown.select-kit");
|
||||
|
||||
if (this.$header()) {
|
||||
if (this.$header().length) {
|
||||
this.$header()
|
||||
.off("blur.select-kit")
|
||||
.off("focus.select-kit")
|
||||
@@ -28,16 +28,17 @@ export default Ember.Mixin.create({
|
||||
.off("keydown.select-kit");
|
||||
}
|
||||
|
||||
if (this.$filterInput()) {
|
||||
if (this.$filterInput().length) {
|
||||
this.$filterInput()
|
||||
.off("change.select-kit")
|
||||
.off("keydown.select-kit")
|
||||
.off("keypress.select-kit");
|
||||
.off("keypress.select-kit")
|
||||
.off("focusout.select-kit");
|
||||
}
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
this._super(...arguments);
|
||||
|
||||
$(document).on("mousedown.select-kit", event => {
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||
@@ -120,6 +121,11 @@ export default Ember.Mixin.create({
|
||||
.on("keypress.select-kit", event => {
|
||||
event.stopPropagation();
|
||||
})
|
||||
.on("focusout.select-kit", event => {
|
||||
if (!Ember.$.contains(this.element, event.relatedTarget)) {
|
||||
this.close(event);
|
||||
}
|
||||
})
|
||||
.on("keydown.select-kit", event => {
|
||||
const keyCode = event.keyCode || event.which;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user