0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed missing outline on <GhInputWithSelect> when focused

refs https://github.com/TryGhost/Team/issues/993

- added calls to `onFocus()` and `onBlur()` arguments inside the trigger when the input is focused/blurred so that the active class is correctly applied by ember-power-select
- removed unnecessary mousedown propagation cancellation, it was a copied from `<GhTokenInput>` where extra mouse handling is necessary for buttons inside tokens
- updated `.gh-input-with-select` styles to add the border when active
This commit is contained in:
Kevin Ansfield 2021-08-26 17:19:00 +01:00
parent e926591c34
commit 23c6547b5b
4 changed files with 35 additions and 34 deletions

View file

@ -54,7 +54,7 @@
@selected={{@selected}}
@selectedItemComponent={{@selectedItemComponent}}
@tabindex="-1"
@triggerClass="ember-power-select-multiple-trigger {{@triggerClass}}"
@triggerClass="ember-power-select-multiple-trigger gh-input-with-select-trigger {{@triggerClass}}"
@triggerComponent={{component (or @triggerComponent "gh-input-with-select/trigger") tabindex=@tabindex}}
@triggerId={{@triggerId}}
@triggerRole={{@triggerRole}}

View file

@ -1,27 +1,24 @@
<div {{on "mousedown" this.captureMousedown}} id="gh-input-with-select-trigger-{{@select.uniqueId}}">
{{#if @extra.inputIcon}}
{{svg-jar @extra.inputIcon class=@extra.inputIconClass}}
{{/if}}
<input
{{did-insert this.registerInput}}
{{did-update this.closeWhenEmpty @select.results}}
{{on "mousedown" this.captureMousedown}}
{{on "input" this.handleInput}}
{{on "keydown" this.handleKeydown}}
{{on "keyup" this.handleKeyup}}
{{on "focus" this.handleFocus}}
{{on "blur" this.handleBlur}}
class="gh-input-with-select-input"
type={{or @extra.inputType "text"}}
autofocus={{@extra.autofocus}}
autocomplete="off"
autocorrect="off"
autocapitalize="off"
value={{@extra.value}}
name="selectSearchTerm" {{!-- contains "search" to prevent Safari showing autocomplete --}}
spellcheck="false"
role="combobox"
placeholder={{@placeholder}}
disabled={{@select.disabled}}
>
</div>
{{#if @extra.inputIcon}}
{{svg-jar @extra.inputIcon class=@extra.inputIconClass}}
{{/if}}
<input
{{did-insert this.registerInput}}
{{did-update this.closeWhenEmpty @select.results}}
{{on "input" this.handleInput}}
{{on "keydown" this.handleKeydown}}
{{on "keyup" this.handleKeyup}}
{{on "focus" this.handleFocus}}
{{on "blur" this.handleBlur}}
class="gh-input-with-select-input"
type={{or @extra.inputType "text"}}
autofocus={{@extra.autofocus}}
autocomplete="off"
autocorrect="off"
autocapitalize="off"
value={{@extra.value}}
name="selectSearchTerm" {{!-- contains "search" to prevent Safari showing autocomplete --}}
spellcheck="false"
role="combobox"
placeholder={{@placeholder}}
disabled={{@select.disabled}}
>

View file

@ -15,11 +15,6 @@ export default class GhSearchInputTrigger extends Component {
}
}
@action
captureMousedown(e) {
e.stopPropagation();
}
@action
handleInput(event) {
let term = event.target.value;
@ -55,6 +50,8 @@ export default class GhSearchInputTrigger extends Component {
if (this.args.extra?.openOnFocus && this.args.select.results.length > 0) {
this.open();
}
this.args.onFocus?.(...arguments);
}
@action
@ -73,6 +70,8 @@ export default class GhSearchInputTrigger extends Component {
this.args.select.actions.search('');
this.close();
}
this.args.onBlur?.(...arguments);
}
@action

View file

@ -341,6 +341,11 @@
}
/* Input with power select */
.gh-input-with-select-trigger.ember-power-select-trigger--active {
border-color: color-mod(var(--green)) !important;
box-shadow: inset 0 0 0 1px var(--green);
}
.gh-input-with-select-input {
border: none;
width: 100%;