FIX: multiple select-kit fixes on mobile

This commit is contained in:
Joffrey JAFFEUX 2018-07-23 12:19:40 -04:00 committed by GitHub
parent eda1462b3b
commit 78419f677d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 36 deletions

View File

@ -22,7 +22,7 @@ export default ComboBox.extend(Tags, {
fullWidthOnMobile: true, fullWidthOnMobile: true,
init() { init() {
this._super(); this._super(...arguments);
this.set("termMatchesForbidden", false); this.set("termMatchesForbidden", false);
this.selectionSelector = ".selected-tag"; 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") @computed("hasReachedMaximum")
caretIcon(hasReachedMaximum) { caretIcon(hasReachedMaximum) {
return hasReachedMaximum ? null : "plus fa-fw"; return hasReachedMaximum ? null : "plus fa-fw";

View File

@ -92,17 +92,6 @@ export default Ember.Component.extend(
this.set("computedContent", []); this.set("computedContent", []);
this.set("highlightedSelection", []); 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")) { if (this.get("nameChanges")) {
this.addObserver( this.addObserver(
`content.@each.${this.get("nameProperty")}`, `content.@each.${this.get("nameProperty")}`,
@ -458,7 +447,7 @@ export default Ember.Component.extend(
clearSelection() { clearSelection() {
this.deselect(this.get("selection")); this.deselect(this.get("selection"));
this.focus(); this.focusFilterOrHeader();
}, },
actions: { actions: {

View File

@ -82,9 +82,7 @@ export default Ember.Mixin.create({
}, },
focus() { focus() {
Ember.run.schedule("afterRender", () => { this.focusFilterOrHeader();
this.$header().focus();
});
}, },
// try to focus filter and fallback to header if not present // 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 // next so we are sure it finised expand/collapse
Ember.run.next(() => { Ember.run.next(() => {
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
if ( if (!context.$filterInput() || !context.$filterInput().is(":visible")) {
(this.site && this.site.isMobileDevice) || if (context.$header()) {
!context.$filterInput() || context.$header().focus();
!context.$filterInput().is(":visible") } else {
) { $(context.element).focus();
context.$header().focus(); }
} else { } else {
context.$filterInput().focus(); context.$filterInput().focus();
} }

View File

@ -16,11 +16,11 @@ export default Ember.Mixin.create({
}, },
willDestroyElement() { willDestroyElement() {
this._super(); this._super(...arguments);
$(document).off("mousedown.select-kit"); $(document).off("mousedown.select-kit");
if (this.$header()) { if (this.$header().length) {
this.$header() this.$header()
.off("blur.select-kit") .off("blur.select-kit")
.off("focus.select-kit") .off("focus.select-kit")
@ -28,16 +28,17 @@ export default Ember.Mixin.create({
.off("keydown.select-kit"); .off("keydown.select-kit");
} }
if (this.$filterInput()) { if (this.$filterInput().length) {
this.$filterInput() this.$filterInput()
.off("change.select-kit") .off("change.select-kit")
.off("keydown.select-kit") .off("keydown.select-kit")
.off("keypress.select-kit"); .off("keypress.select-kit")
.off("focusout.select-kit");
} }
}, },
didInsertElement() { didInsertElement() {
this._super(); this._super(...arguments);
$(document).on("mousedown.select-kit", event => { $(document).on("mousedown.select-kit", event => {
if (!this.element || this.isDestroying || this.isDestroyed) { if (!this.element || this.isDestroying || this.isDestroyed) {
@ -120,6 +121,11 @@ export default Ember.Mixin.create({
.on("keypress.select-kit", event => { .on("keypress.select-kit", event => {
event.stopPropagation(); event.stopPropagation();
}) })
.on("focusout.select-kit", event => {
if (!Ember.$.contains(this.element, event.relatedTarget)) {
this.close(event);
}
})
.on("keydown.select-kit", event => { .on("keydown.select-kit", event => {
const keyCode = event.keyCode || event.which; const keyCode = event.keyCode || event.which;

View File

@ -11,11 +11,16 @@
.future-date-input-selector-datetime { .future-date-input-selector-datetime {
color: lighten($primary, 40%); color: lighten($primary, 40%);
font-size: $font-down-1; margin-left: 5px;
} }
.future-date-input-selector-icons { .future-date-input-selector-icons {
width: 25px; margin-right: 5px;
}
.btn-clear {
padding: 0;
margin-left: 5px;
} }
.future-date-input-selector-row { .future-date-input-selector-row {

View File

@ -58,14 +58,16 @@
.select-kit-collection { .select-kit-collection {
.collection-header { .collection-header {
max-height: 125px; max-height: 125px;
overflow-y: auto; overflow: hidden;
flex: 1 0 auto; flex: 1 0 auto;
border-bottom: 1px solid $primary-low;
.selected-tags { .selected-tags {
display: flex; display: flex;
padding: 4px 8px; padding: 4px;
flex-wrap: wrap; flex-wrap: wrap;
border-bottom: 1px solid $primary-low; margin: -2px;
overflow: hidden;
} }
.selected-tag { .selected-tag {

View File

@ -64,9 +64,9 @@
} }
.choices { .choices {
margin: 0; margin: 1px;
box-sizing: border-box; box-sizing: border-box;
display: inline-flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
flex-wrap: wrap; flex-wrap: wrap;
@ -79,7 +79,7 @@
justify-content: space-between; justify-content: space-between;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row; flex-direction: row;
margin: 2px; margin: 1px;
} }
.filter { .filter {

View File

@ -2,7 +2,7 @@
&.dropdown-select-box { &.dropdown-select-box {
.select-kit-collection { .select-kit-collection {
max-height: 200px; max-height: 200px;
overflow-y: scroll; overflow-y: auto;
} }
} }
} }