File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
packages/core/src/lib/nav-dropdown Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,6 @@ describe('NavDropdown', () => {
5959 expect ( within ( menuitem ) . getByText ( 'stable' ) ) . toBeInTheDocument ( ) ;
6060 } ) ;
6161
62-
6362 it ( 'opens menu with Space when button is focused' , async ( ) => {
6463 const user = userEvent . setup ( ) ;
6564 render ( Subject , {
@@ -69,7 +68,7 @@ describe('NavDropdown', () => {
6968 const button = screen . getByRole ( 'button' ) ;
7069 button . focus ( ) ;
7170 await user . keyboard ( ' ' ) ;
72-
71+
7372 expect ( screen . getByRole ( 'menu' ) ) . toBeInTheDocument ( ) ;
7473 expect ( button ) . toHaveAttribute ( 'aria-expanded' , 'true' ) ;
7574 } ) ;
@@ -85,7 +84,7 @@ describe('NavDropdown', () => {
8584 expect ( screen . getByRole ( 'menu' ) ) . toBeInTheDocument ( ) ;
8685
8786 await user . keyboard ( '{Escape}' ) ;
88-
87+
8988 expect ( screen . queryByRole ( 'menu' ) ) . not . toBeInTheDocument ( ) ;
9089 expect ( button ) . toHaveAttribute ( 'aria-expanded' , 'false' ) ;
9190 } ) ;
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ const handleMenuItemKeydown = createHandleKey({
3232 closeDropdown ();
3333 buttonElement ?.focus ();
3434 activeIndex = - 1 ;
35- }
35+ },
3636});
3737
3838const handleClickOutside = (element : Element ) => {
@@ -57,7 +57,8 @@ $: if (isOpen) {
5757 >
5858 <div class =" flex items-center justify-between" >
5959 <span class =" block truncate text-xs" >
60- {options .find ((opt ) => opt .href === selectedHref )?.label ?? ' Latest Version' }
60+ {options .find ((opt ) => opt .href === selectedHref )?.label ??
61+ ' Latest Version' }
6162 </span >
6263 <Icon
6364 name =" chevron-down"
@@ -88,8 +89,12 @@ $: if (isOpen) {
8889 aria-current ={href === selectedHref ? ' page' : ' false' }
8990 on:click ={closeDropdown }
9091 on:keydown ={handleMenuItemKeydown }
91- on:focus ={() => {activeIndex = i }}
92- on:blur ={() => {activeIndex = - 1 }}
92+ on:focus ={() => {
93+ activeIndex = i ;
94+ }}
95+ on:blur ={() => {
96+ activeIndex = - 1 ;
97+ }}
9398 tabindex =" 0"
9499 >
95100 <div class =" flex items-center text-xs" >
You can’t perform that action at this time.
0 commit comments