AutoComplete: context option updates #7073
Labels
Type: Enhancement
Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone
Describe the bug
When attempting to add dynamic
data-attributes
(such asdata-testid
) to children of components likeAutoComplete
orDropdown
(and potentially other components), it is only possible by usingslot
andslotProps
. This requires extending the template with aslot
, even for simple use cases like adding atest-id
to a child component (e.g.,AutoComplete
'sOption
).Pull Request Link
No response
Reason for not contributing a PR
Other Reason
No response
Reproducer
https://stackblitz.com/edit/primevue-4-vite-issue-template-mqr2pvyh?file=src%2FApp.vue
Environment
"nuxt": "^3.14.1592"
Vue version
3.5.13
PrimeVue version
4.2.4
Node version
22.4.1
Browser(s)
No response
Steps to reproduce the behavior
When using
pt
in a component likeAutoComplete
(or whichever component where you want to add attributes viapt
), try to add it like:If you add this you will see this as result in your DOM:
Because optionProps is of the AutoComplete instance and contains:
Which can not give anything focussed on the option
Expected behavior
It would be nice to have something like this pt for option (or any other component to be frank).
Or:
Provide the option index in the context so that you can manually extract the option information through something like:
option.props.suggestions[options.context.index]
The text was updated successfully, but these errors were encountered: