Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
autofocusattribute won't work reliably for dynamically shown dropdowns.The HTML
autofocusattribute only triggers during initial page load, not when elements are added to the DOM dynamically or when a hidden component becomes visible. Since this component is used in asset dropdowns that appear on user interaction, the search input won't receive focus automatically.Apply this diff to implement programmatic focus that works with dynamically shown components:
<i v-else class="mr-2 icon-[lucide--search] size-4" /> <input + ref="searchInputRef" v-model="searchQuery" type="text" - autofocus :class="resetInputStyle" :placeholder="$t('g.search')" />🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai What if this is in the context of a
dialog?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 27
🏁 Script executed:
Length of output: 535
🏁 Script executed:
Length of output: 6255
🏁 Script executed:
Length of output: 1887
🏁 Script executed:
Length of output: 2835
🏁 Script executed:
Length of output: 34
🏁 Script executed:
Length of output: 673
@DrJKL You're absolutely right to question this! Looking at the code structure,
FormDropdownMenuActionsis indeed rendered inside a PrimeVuePopovercomponent (inFormDropdown.vue), which behaves similarly to a dialog.This means both the
autofocusattribute AND my suggestedonMountedapproach won't work reliably, because:Here's the proper solution that accounts for the Popover context:
Option 1: Watch for visibility prop (Recommended)
In
FormDropdown.vue, pass theisOpenstate down:Then in
FormDropdownMenu.vue, pass it through:Finally in
FormDropdownMenuActions.vue:Option 2: Use Popover's @show event
Add
@showhandler inFormDropdown.vueand emit an event that triggers focus in the child component.Would you like me to provide a complete implementation for either option?
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://html.spec.whatwg.org/multipage/interaction.html#attr-fe-autofocus
See the notes about dialogs and popovers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai See the notes about dialogs and popovers.
https://html.spec.whatwg.org/multipage/interaction.html#attr-fe-autofocus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
💡 Result:
Short answer
Key points (spec-backed)
Sources
@DrJKL You're absolutely correct, and I apologize for the confusion!
I was wrong in my initial assessment. According to the HTML specification, the
autofocusattribute is honored when a dialog is shown or when an element with a popover attribute becomes active. The spec defines an "autofocus scoping root" algorithm that finds the nearest dialog or popover element, and the focus is applied when that scope becomes visible.Since the
FormDropdownMenuActionscomponent is rendered inside a PrimeVuePopover, theautofocusattribute in the original PR implementation is correct and will work as intended. When the popover opens, the browser will automatically focus the search input according to the spec.The original implementation is the right approach—no additional JavaScript focus management is needed. Thank you for the correction!
🧠 Learnings used