File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,20 @@ describe('MenuContainer', () => {
280
280
expect ( firstItem ) . toHaveFocus ( ) ;
281
281
} ) ;
282
282
283
+ it ( 'does not focus default value on click' , async ( ) => {
284
+ const { getByTestId, getByText } = render (
285
+ < TestMenu items = { ITEMS } defaultFocusedValue = "plant-04" />
286
+ ) ;
287
+ const trigger = getByTestId ( 'trigger' ) ;
288
+ const item = getByText ( 'Succulent' ) ;
289
+
290
+ await act ( async ( ) => {
291
+ await user . click ( trigger ) ;
292
+ } ) ;
293
+
294
+ expect ( item ) . not . toHaveFocus ( ) ;
295
+ } ) ;
296
+
283
297
it ( 'focuses defaultFocusedValue on ArrowDown keydown' , async ( ) => {
284
298
const { getByText, getByTestId } = render (
285
299
< TestMenu items = { ITEMS } defaultFocusedValue = "plant-04" />
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ export const useMenu = <T extends HTMLElement = HTMLElement, M extends HTMLEleme
97
97
const focusTriggerRef = useRef < boolean > ( false ) ;
98
98
99
99
const [ state , dispatch ] = useReducer ( stateReducer , {
100
- focusedValue : focusedValue || defaultFocusedValue ,
100
+ focusedValue,
101
101
isExpanded : isExpanded || defaultExpanded ,
102
102
selectedItems : initialSelectedItems ,
103
103
valuesRef : values ,
You can’t perform that action at this time.
0 commit comments