mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Fixed tabbing in and out of <GhInputWithSelect>
refs https://github.com/TryGhost/Team/issues/1009 - setting `tabIndex="-1"` on the trigger prevents the trigger container receiving focus rather than the container input element (fixes general tabbing in and out) - added extra blur handling to the input element so that it is not left in an open dropdown state when tabbing out
This commit is contained in:
parent
b5f43a7e9d
commit
ed85901607
2 changed files with 12 additions and 2 deletions
|
@ -53,7 +53,7 @@
|
||||||
@searchPlaceholder={{@searchPlaceholder}}
|
@searchPlaceholder={{@searchPlaceholder}}
|
||||||
@selected={{@selected}}
|
@selected={{@selected}}
|
||||||
@selectedItemComponent={{@selectedItemComponent}}
|
@selectedItemComponent={{@selectedItemComponent}}
|
||||||
@tabindex={{@tabindex}}
|
@tabindex="-1"
|
||||||
@triggerClass="ember-power-select-multiple-trigger {{@triggerClass}}"
|
@triggerClass="ember-power-select-multiple-trigger {{@triggerClass}}"
|
||||||
@triggerComponent={{component (or @triggerComponent "gh-input-with-select/trigger") tabindex=@tabindex}}
|
@triggerComponent={{component (or @triggerComponent "gh-input-with-select/trigger") tabindex=@tabindex}}
|
||||||
@triggerId={{@triggerId}}
|
@triggerId={{@triggerId}}
|
||||||
|
|
|
@ -58,7 +58,17 @@ export default class GhSearchInputTrigger extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
handleBlur() {
|
handleBlur(event) {
|
||||||
|
if (event?.relatedTarget) {
|
||||||
|
const thisInputTrigger = this.inputElem.closest('.ember-basic-dropdown-trigger');
|
||||||
|
const relatedInputTrigger = event.relatedTarget.closest('.ember-basic-dropdown-trigger');
|
||||||
|
|
||||||
|
if (relatedInputTrigger !== thisInputTrigger) {
|
||||||
|
this.args.select.actions.search('');
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.args.extra.value && this.args.select.searchText === this.args.extra.value) {
|
if (this.args.extra.value && this.args.select.searchText === this.args.extra.value) {
|
||||||
this.args.select.actions.search('');
|
this.args.select.actions.search('');
|
||||||
this.close();
|
this.close();
|
||||||
|
|
Loading…
Add table
Reference in a new issue