@@ -130,20 +130,25 @@ class MaterialFabMenuComponent extends Object
130130
131131 bool get hasIcons => _viewModel.hasIcons;
132132
133- /// Keypress callback is used to handle Up and Down keys.
133+ /// Keypress callback is used to handle UP and DOWN keys.
134134 ///
135135 /// Unprintable keys use this listener while printable keys
136136 /// use [handleKeyPress] .
137137 /// Enabling [MaterialFabMenu] to be opened with the keyboard improves
138138 /// accessibility and improves with a11y navigation.
139139 @HostListener ('keydown' )
140140 void handleKeyDown (KeyboardEvent event) {
141- if (event.keyCode == KeyCode .DOWN || event.keyCode == KeyCode .UP ) {
142- openMenuAndActivateFirstItem ();
141+ switch (event.keyCode) {
142+ case KeyCode .UP :
143+ openMenuAndActivateLastItem ();
144+ break ;
145+ case KeyCode .DOWN :
146+ openMenuAndActivateFirstItem ();
147+ break ;
143148 }
144149 }
145150
146- /// Keypress callback is used to handle Enter and Space keys.
151+ /// Keypress callback is used to handle ENTER and SPACE keys.
147152 @HostListener ('keypress' )
148153 void handleKeyPress (KeyboardEvent event) {
149154 if (event.keyCode == KeyCode .ENTER || isSpaceKey (event)) {
@@ -169,6 +174,15 @@ class MaterialFabMenuComponent extends Object
169174 _viewModel.trigger ();
170175 }
171176
177+ /// Sets the [activeModel.menu] and activates the last item in the menu.
178+ void openMenuAndActivateLastItem () {
179+ if (hasMenu) {
180+ activeModel.menu = menuItem.subMenu;
181+ activeModel.activateLast ();
182+ }
183+ _viewModel.trigger ();
184+ }
185+
172186 void onPopupOpened () {
173187 if (_menuVisible) return ;
174188 _menuVisible = true ;
0 commit comments