File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
packages/components/src/components/tab-item Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ useDefaultProps<DBTabItemProps>({});
2727
2828export default function DBTabItem ( props : DBTabItemProps ) {
2929 const _ref = useRef < HTMLInputElement | any > ( null ) ;
30+
3031 // jscpd:ignore-start
3132 const state = useStore < DBTabItemState > ( {
3233 _selected : false ,
@@ -49,18 +50,6 @@ export default function DBTabItem(props: DBTabItemProps) {
4950 props . onChange ( event ) ;
5051 }
5152
52- // We have different ts types in different frameworks, so we need to use any here
53-
54- useTarget ( {
55- stencil : ( ) => {
56- const selected = ( event . target as any ) ?. [ 'checked' ] ;
57- state . _selected = getBooleanAsString ( selected ) ;
58- } ,
59- default : ( ) => {
60- state . _selected = ( event . target as any ) ?. [ 'checked' ] ;
61- }
62- } ) ;
63-
6453 useTarget ( {
6554 angular : ( ) =>
6655 handleFrameworkEventAngular ( state , event , 'checked' ) ,
@@ -82,6 +71,14 @@ export default function DBTabItem(props: DBTabItemProps) {
8271
8372 useTarget ( { react : ( ) => state . handleNameAttribute ( ) } ) ;
8473 state . initialized = false ;
74+
75+ // deselect this tab when another tab in tablist is selected
76+ _ref . closest ( '[role=tablist]' ) ?. addEventListener (
77+ 'change' ,
78+ ( event : any ) => {
79+ state . _selected = event . target === _ref ;
80+ }
81+ ) ;
8582 }
8683 } , [ _ref , state . initialized ] ) ;
8784
You can’t perform that action at this time.
0 commit comments