Skip to content

Commit

Permalink
Handle blur directly in input component instead global
Browse files Browse the repository at this point in the history
  • Loading branch information
mkszepp committed Dec 8, 2024
1 parent 41b6bb8 commit d1264e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 0 additions & 3 deletions ember-power-select/src/components/power-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,6 @@ export default class PowerSelectComponent extends Component<PowerSelectSignature
if (!this.isDestroying) {
scheduleTask(this, 'actions', this._updateIsActive, false);
}
if (this.searchFieldPosition === 'trigger') {
this.searchText = '';
}
if (this.args.onBlur) {
this.args.onBlur(this.storedAPI, event);
}
Expand Down
2 changes: 1 addition & 1 deletion ember-power-select/src/components/power-select/input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
aria-describedby={{@ariaDescribedBy}}
{{on "input" this.handleInput}}
{{on "focus" @onFocus}}
{{on "blur" @onBlur}}
{{on "blur" this.handleBlur}}
{{on "keydown" this.handleKeydown}}
{{this.setupInput}}
>
Expand Down
11 changes: 11 additions & 0 deletions ember-power-select/src/components/power-select/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ export default class PowerSelectInput extends Component<PowerSelectInputSignatur
}
}

@action
handleBlur(event: Event) {
if (this.args.searchFieldPosition === 'trigger') {
this.args.select.searchText = '';
}

if (this.args.onBlur(event)) {
return false;
}
}

setupInput = modifier(
(el: HTMLElement) => {
if (this.didSetup) {
Expand Down

0 comments on commit d1264e1

Please sign in to comment.