File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
packages/vuetify/src/components/VList Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -233,6 +233,7 @@ export const VListItem = genericComponent<VListItemSlots>()({
233233 } satisfies ListItemSlot ) )
234234
235235 function onClick ( e : MouseEvent ) {
236+ if ( props . disabled ) e . preventDefault ( )
236237 emit ( 'click' , e )
237238 if ( [ 'INPUT' , 'TEXTAREA' ] . includes ( ( e . target as Element ) ?. tagName ) ) return
238239
Original file line number Diff line number Diff line change 1+ // Components
2+ import { VList , VListItem } from '..'
3+
4+ // Utilities
5+ import { render , screen , userEvent } from '@test'
6+
7+ describe ( 'VListItem' , ( ) => {
8+ // https://github.com/vuetifyjs/vuetify/issues/22172
9+ it ( 'should not navigate when disabled item with href is clicked' , async ( ) => {
10+ render ( ( ) => (
11+ < VList >
12+ < VListItem href = "/about" disabled title = "Link" >
13+ { {
14+ append : ( ) => < span class = "append-content" > append</ span > ,
15+ } }
16+ </ VListItem >
17+ </ VList >
18+ ) )
19+
20+ const item = screen . getByCSS ( '.v-list-item' )
21+ const event = new MouseEvent ( 'click' , { bubbles : true , cancelable : true } )
22+ item . dispatchEvent ( event )
23+
24+ expect ( event . defaultPrevented ) . toBe ( true )
25+ } )
26+ } )
You can’t perform that action at this time.
0 commit comments