mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 10:28:20 +08:00
FIX: select-kit refactoring
- improve mini-tag-chooser keyboard behavior - all multil select now respond to select all and left/right arrows - improve events handling - many minor tweaks
This commit is contained in:
@ -6,6 +6,7 @@ export default Ember.Mixin.create({
|
||||
|
||||
this._previousScrollParentOverflow = null;
|
||||
this._previousCSSContext = null;
|
||||
this.selectionSelector = ".choice";
|
||||
this.filterInputSelector = ".filter-input";
|
||||
this.rowSelector = ".select-kit-row";
|
||||
this.collectionSelector = ".select-kit-collection";
|
||||
@ -58,36 +59,42 @@ export default Ember.Mixin.create({
|
||||
this.setProperties({ isFocused: false });
|
||||
},
|
||||
|
||||
// try to focus filter and fallback to header if not present
|
||||
focus() {
|
||||
Ember.run.schedule("afterRender", () => {
|
||||
if ((!this.get("filterable")) || !this.$filterInput().is(":visible")) {
|
||||
this.$header().focus();
|
||||
} else {
|
||||
this.$filterInput().focus();
|
||||
}
|
||||
this.$header().focus();
|
||||
});
|
||||
},
|
||||
|
||||
// try to focus filter and fallback to header if not present
|
||||
focusFilterOrHeader() {
|
||||
// next so we are sure it finised expand/collapse
|
||||
Ember.run.next(() => {
|
||||
Ember.run.schedule("afterRender", () => {
|
||||
if (!this.$filterInput().is(":visible")) {
|
||||
this.$header().focus();
|
||||
} else {
|
||||
this.$filterInput().focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
expand() {
|
||||
if (this.get("isExpanded") === true) return;
|
||||
if (this.get("isExpanded")) return;
|
||||
this.setProperties({ isExpanded: true, renderedBodyOnce: true, isFocused: true });
|
||||
this._setCollectionHeaderComputedContent();
|
||||
this._setHeaderComputedContent();
|
||||
this.focus();
|
||||
this.focusFilterOrHeader();
|
||||
this.autoHighlight();
|
||||
},
|
||||
|
||||
collapse() {
|
||||
this.set("isExpanded", false);
|
||||
Ember.run.schedule("afterRender", () => this._removeFixedPosition() );
|
||||
this._setHeaderComputedContent();
|
||||
},
|
||||
|
||||
// lose focus of the component in two steps
|
||||
// first collapse and keep focus and then remove focus
|
||||
unfocus(event) {
|
||||
if (this.get("isExpanded") === true) {
|
||||
if (this.get("isExpanded")) {
|
||||
this.collapse(event);
|
||||
this.focus(event);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user