mirror of
https://github.com/discourse/discourse.git
synced 2025-09-04 08:47:37 +08:00
FIX: display keyboard on mobile when focusing mini-tag-chooser
This commit is contained in:
parent
49400337b6
commit
057fa049e6
6 changed files with 30 additions and 11 deletions
|
@ -6,6 +6,7 @@ const { get, isEmpty, run, makeArray } = Ember;
|
||||||
|
|
||||||
export default ComboBox.extend(Tags, {
|
export default ComboBox.extend(Tags, {
|
||||||
allowContentReplacement: true,
|
allowContentReplacement: true,
|
||||||
|
headerComponent: "mini-tag-chooser/mini-tag-chooser-header",
|
||||||
pluginApiIdentifiers: ["mini-tag-chooser"],
|
pluginApiIdentifiers: ["mini-tag-chooser"],
|
||||||
attributeBindings: ["categoryId"],
|
attributeBindings: ["categoryId"],
|
||||||
classNames: ["mini-tag-chooser"],
|
classNames: ["mini-tag-chooser"],
|
||||||
|
@ -65,12 +66,18 @@ export default ComboBox.extend(Tags, {
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
this.send("removeTag", $(event.target).attr("data-value"));
|
this.send("removeTag", $(event.target).attr("data-value"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".select-kit-header").on("focus.mini-tag-chooser", ".selected-name", (event) => {
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
this.focus(event);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super();
|
this._super();
|
||||||
|
|
||||||
$(".select-kit-body").off("click.mini-tag-chooser");
|
$(".select-kit-body").off("click.mini-tag-chooser");
|
||||||
|
$(".select-kit-header").off("focus.mini-tag-chooser");
|
||||||
},
|
},
|
||||||
|
|
||||||
didPressEscape(event) {
|
didPressEscape(event) {
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";
|
||||||
|
|
||||||
|
export default SelectKitHeaderComponent.extend({
|
||||||
|
layoutName: "select-kit/templates/components/mini-tag-chooser/mini-tag-chooser-header",
|
||||||
|
classNames: "mini-tag-chooser-header",
|
||||||
|
});
|
|
@ -260,7 +260,7 @@ export default SelectKitComponent.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
didSelect() {
|
didSelect() {
|
||||||
this.focusFilterOrHeader();
|
this.focus();
|
||||||
this.autoHighlight();
|
this.autoHighlight();
|
||||||
|
|
||||||
applyOnSelectPluginApiCallbacks(
|
applyOnSelectPluginApiCallbacks(
|
||||||
|
@ -278,7 +278,7 @@ export default SelectKitComponent.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
didDeselect(rowComputedContentItems) {
|
didDeselect(rowComputedContentItems) {
|
||||||
this.focusFilterOrHeader();
|
this.focus();
|
||||||
this.autoHighlight();
|
this.autoHighlight();
|
||||||
this._boundaryActionHandler("onDeselect", rowComputedContentItems);
|
this._boundaryActionHandler("onDeselect", rowComputedContentItems);
|
||||||
},
|
},
|
||||||
|
|
|
@ -58,15 +58,10 @@ export default Ember.Mixin.create({
|
||||||
this.setProperties({ isFocused: false });
|
this.setProperties({ isFocused: false });
|
||||||
},
|
},
|
||||||
|
|
||||||
// force the component in a known default state
|
|
||||||
focus() {
|
|
||||||
Ember.run.schedule("afterRender", () => 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
|
||||||
focusFilterOrHeader() {
|
focus() {
|
||||||
Ember.run.schedule("afterRender", () => {
|
Ember.run.schedule("afterRender", () => {
|
||||||
if ((this.site && this.site.isMobileDevice) || !this.$filterInput().is(":visible")) {
|
if ((!this.get("filterable")) || !this.$filterInput().is(":visible")) {
|
||||||
this.$header().focus();
|
this.$header().focus();
|
||||||
} else {
|
} else {
|
||||||
this.$filterInput().focus();
|
this.$filterInput().focus();
|
||||||
|
@ -77,10 +72,10 @@ export default Ember.Mixin.create({
|
||||||
expand() {
|
expand() {
|
||||||
if (this.get("isExpanded") === true) return;
|
if (this.get("isExpanded") === true) return;
|
||||||
this.setProperties({ isExpanded: true, renderedBodyOnce: true, isFocused: true });
|
this.setProperties({ isExpanded: true, renderedBodyOnce: true, isFocused: true });
|
||||||
this.focusFilterOrHeader();
|
|
||||||
this.autoHighlight();
|
|
||||||
this._setCollectionHeaderComputedContent();
|
this._setCollectionHeaderComputedContent();
|
||||||
this._setHeaderComputedContent();
|
this._setHeaderComputedContent();
|
||||||
|
this.focus();
|
||||||
|
this.autoHighlight();
|
||||||
},
|
},
|
||||||
|
|
||||||
collapse() {
|
collapse() {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{{input class="selected-name" value=label readonly="readonly"}}
|
|
@ -23,6 +23,16 @@
|
||||||
box-shadow: shadow("focus")
|
box-shadow: shadow("focus")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.select-kit-header {
|
||||||
|
.selected-name {
|
||||||
|
margin: 0;
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
outline: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.select-kit-filter {
|
.select-kit-filter {
|
||||||
border-top: 0;
|
border-top: 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue