fix(VListItem): prevent navigation when disabled link is clicked#22713
Closed
mixelburg wants to merge 2 commits intovuetifyjs:masterfrom
Closed
fix(VListItem): prevent navigation when disabled link is clicked#22713mixelburg wants to merge 2 commits intovuetifyjs:masterfrom
mixelburg wants to merge 2 commits intovuetifyjs:masterfrom
Conversation
Contributor
|
I can still focus the list item and click |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #22172
When a
v-list-itemhashreforto(renders as<a>) and isdisabled, clicking content inside a slot (e.g. a badge in theappendslot) still causes the browser to follow the link.The root cause: the
onClickhandler returns early when!isClickable.value(which covers the disabled case), but native anchor click behaviour fires independently of our handler —preventDefault()was never called.Fix: call
e.preventDefault()at the start ofonClickwhenprops.disabledis true. This is the same pattern used by other Vuetify components (e.g.VBtn) to block navigation on disabled link elements.Added a browser test verifying that clicking a disabled list item with
hrefdoes not navigate (event.defaultPrevented === true).