Skip to content

Commit

Permalink
Fix focus helper for non-native inputs
Browse files Browse the repository at this point in the history
Fixes #6347
  • Loading branch information
distantnative committed Jul 22, 2024
1 parent 744a004 commit c89b052
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions panel/src/components/Forms/Field/BlocksField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
icon="add"
variant="filled"
size="xs"
class="input-focus"
@click="$refs.blocks.choose(value.length)"
/>
<k-button
Expand Down
1 change: 1 addition & 0 deletions panel/src/components/Forms/Field/LayoutField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
icon="add"
variant="filled"
size="xs"
class="input-focus"
@click="$refs.layouts.select(0)"
/>
<k-button
Expand Down
2 changes: 1 addition & 1 deletion panel/src/components/Forms/Input/TagsInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ref="toggle"
:autofocus="autofocus"
:disabled="disabled"
class="k-tags-input-toggle k-tags-navigatable"
class="k-tags-input-toggle k-tags-navigatable input-focus"
size="xs"
icon="add"
@click="$refs.create.open()"
Expand Down
11 changes: 5 additions & 6 deletions panel/src/helpers/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ export default function focus(element, field) {
}

const selectors = [
"[autofocus]",
"[data-autofocus]",
"input",
"textarea",
"select",
"[contenteditable=true]",
// prioritize elements that have set autofocus explicitly
":where([autofocus], [data-autofocus])",
// treat all types of inputs equally as second-best
":where(input, textarea, select, [contenteditable=true], .input-focus)",
// prefer submit button over other buttons
"[type=submit]",
"button"
];
Expand Down

0 comments on commit c89b052

Please sign in to comment.