@@ -156,7 +156,7 @@ impl FilterPopup {
156156
157157 // Create the tabs
158158 let tabs = Tabs :: new ( vec ! [
159- Line :: from( "User & Name" ) ,
159+ Line :: from( "User & Name & Node " ) ,
160160 Line :: from( "States" ) ,
161161 Line :: from( "Partitions" ) ,
162162 Line :: from( "QoS" ) ,
@@ -460,7 +460,7 @@ impl FilterPopup {
460460 self . input_mode = false ;
461461 } else {
462462 // Cycle through focusable elements
463- // self.cycle_focus();
463+ self . cycle_focus ( ) ;
464464 }
465465 return FilterAction :: None ;
466466 }
@@ -572,18 +572,29 @@ impl FilterPopup {
572572 if selected > 0 {
573573 self . state_list_state . select ( Some ( selected - 1 ) ) ;
574574 }
575+ if selected == 0 {
576+ // If already at the top, move to bottom
577+ self . state_list_state . select ( Some ( all_states. len ( ) - 1 ) ) ;
578+ }
575579 }
576580 FilterFocus :: Partitions => {
577581 let selected = self . partition_list_state . selected ( ) . unwrap_or ( 0 ) ;
578582 if selected > 0 {
579583 self . partition_list_state . select ( Some ( selected - 1 ) ) ;
580584 }
585+ if selected == 0 {
586+ self . partition_list_state
587+ . select ( Some ( all_partitions. len ( ) - 1 ) ) ;
588+ }
581589 }
582590 FilterFocus :: QoS => {
583591 let selected = self . qos_list_state . selected ( ) . unwrap_or ( 0 ) ;
584592 if selected > 0 {
585593 self . qos_list_state . select ( Some ( selected - 1 ) ) ;
586594 }
595+ if selected == 0 {
596+ self . qos_list_state . select ( Some ( all_qos. len ( ) - 1 ) ) ;
597+ }
587598 }
588599 FilterFocus :: NodeFilter => {
589600 // Move focus to the name filter if up is pressed in the node filter
@@ -597,6 +608,10 @@ impl FilterPopup {
597608 // Move focus to node filter from buttons
598609 self . focus = FilterFocus :: NodeFilter ;
599610 }
611+ FilterFocus :: Username => {
612+ // If already at the top, move to the last focusable element
613+ self . focus = FilterFocus :: NodeFilter ;
614+ }
600615 _ => { }
601616 }
602617 FilterAction :: None
@@ -608,39 +623,37 @@ impl FilterPopup {
608623 if selected < all_states. len ( ) - 1 {
609624 self . state_list_state . select ( Some ( selected + 1 ) ) ;
610625 }
626+ if selected == all_states. len ( ) - 1 {
627+ // If already at the bottom, move to top
628+ self . state_list_state . select ( Some ( 0 ) ) ;
629+ }
611630 }
612631 FilterFocus :: Partitions => {
613632 let selected = self . partition_list_state . selected ( ) . unwrap_or ( 0 ) ;
614633 if selected < all_partitions. len ( ) - 1 {
615634 self . partition_list_state . select ( Some ( selected + 1 ) ) ;
616635 }
636+ if selected == all_partitions. len ( ) - 1 {
637+ self . partition_list_state . select ( Some ( 0 ) ) ;
638+ }
617639 }
618640 FilterFocus :: QoS => {
619641 let selected = self . qos_list_state . selected ( ) . unwrap_or ( 0 ) ;
620642 if selected < all_qos. len ( ) - 1 {
621643 self . qos_list_state . select ( Some ( selected + 1 ) ) ;
622644 }
645+ if selected == all_qos. len ( ) - 1 {
646+ self . qos_list_state . select ( Some ( 0 ) ) ;
647+ }
623648 }
624649 FilterFocus :: Username => {
625- // Move focus to the name filter if down is pressed in the username field
626- if self . input_mode {
627- self . input_mode = false ;
628- }
629650 self . focus = FilterFocus :: NameFilter ;
630651 }
631652 FilterFocus :: NameFilter => {
632- // Move focus to the node filter if down is pressed in the name filter
633- if self . input_mode {
634- self . input_mode = false ;
635- }
636653 self . focus = FilterFocus :: NodeFilter ;
637654 }
638655 FilterFocus :: NodeFilter => {
639- // Move focus to the apply button if down is pressed in the node filter
640- if self . input_mode {
641- self . input_mode = false ;
642- }
643- self . focus = FilterFocus :: ApplyButton ;
656+ self . focus = FilterFocus :: Username ;
644657 }
645658 _ => { }
646659 }
@@ -651,16 +664,28 @@ impl FilterPopup {
651664 if self . tab_index > 0 {
652665 self . tab_index -= 1 ;
653666 self . update_focus_for_tab ( ) ;
667+ return FilterAction :: None ;
668+ } else if self . tab_index == 0 {
669+ self . tab_index = 3 ; // Wrap around to last tab
670+ self . update_focus_for_tab ( ) ;
671+ return FilterAction :: None ;
672+ } else {
673+ return FilterAction :: None ; // No change if already at first tab
654674 }
655- FilterAction :: None
656675 }
657676 KeyCode :: Right => {
658677 // Change tab
659678 if self . tab_index < 3 {
660679 self . tab_index += 1 ;
661680 self . update_focus_for_tab ( ) ;
681+ return FilterAction :: None ;
682+ } else if self . tab_index == 3 {
683+ self . tab_index = 0 ; // Wrap around to first tab
684+ self . update_focus_for_tab ( ) ;
685+ return FilterAction :: None ;
686+ } else {
687+ return FilterAction :: None ; // No change if already at last tab
662688 }
663- FilterAction :: None
664689 }
665690 _ => FilterAction :: None ,
666691 }
@@ -746,6 +771,30 @@ impl FilterPopup {
746771 }
747772 FilterAction :: None
748773 }
774+ KeyCode :: Up => {
775+ //quit input mode and cycle focus up
776+ self . input_mode = false ;
777+ // Cycle focus up
778+ match self . focus {
779+ FilterFocus :: Username => self . focus = FilterFocus :: NodeFilter ,
780+ FilterFocus :: NameFilter => self . focus = FilterFocus :: Username ,
781+ FilterFocus :: NodeFilter => self . focus = FilterFocus :: NameFilter ,
782+ _ => { }
783+ }
784+ FilterAction :: None
785+ }
786+ KeyCode :: Down => {
787+ //quit input mode and cycle focus down
788+ self . input_mode = false ;
789+ // Cycle focus down
790+ match self . focus {
791+ FilterFocus :: Username => self . focus = FilterFocus :: NameFilter ,
792+ FilterFocus :: NameFilter => self . focus = FilterFocus :: NodeFilter ,
793+ FilterFocus :: NodeFilter => self . focus = FilterFocus :: Username ,
794+ _ => { }
795+ }
796+ FilterAction :: None
797+ }
749798 _ => FilterAction :: None ,
750799 }
751800 }
@@ -801,7 +850,11 @@ impl FilterPopup {
801850 0 => {
802851 // User tab
803852 match self . focus {
804- FilterFocus :: States | FilterFocus :: Partitions | FilterFocus :: QoS => {
853+ FilterFocus :: States
854+ | FilterFocus :: Partitions
855+ | FilterFocus :: QoS
856+ | FilterFocus :: ApplyButton
857+ | FilterFocus :: CancelButton => {
805858 self . focus = FilterFocus :: Username ;
806859 }
807860 _ => { }
@@ -814,7 +867,9 @@ impl FilterPopup {
814867 | FilterFocus :: NameFilter
815868 | FilterFocus :: NodeFilter
816869 | FilterFocus :: Partitions
817- | FilterFocus :: QoS => {
870+ | FilterFocus :: QoS
871+ | FilterFocus :: ApplyButton
872+ | FilterFocus :: CancelButton => {
818873 self . focus = FilterFocus :: States ;
819874 }
820875 _ => { }
@@ -827,7 +882,9 @@ impl FilterPopup {
827882 | FilterFocus :: NameFilter
828883 | FilterFocus :: NodeFilter
829884 | FilterFocus :: States
830- | FilterFocus :: QoS => {
885+ | FilterFocus :: QoS
886+ | FilterFocus :: ApplyButton
887+ | FilterFocus :: CancelButton => {
831888 self . focus = FilterFocus :: Partitions ;
832889 }
833890 _ => { }
@@ -840,7 +897,9 @@ impl FilterPopup {
840897 | FilterFocus :: NameFilter
841898 | FilterFocus :: NodeFilter
842899 | FilterFocus :: States
843- | FilterFocus :: Partitions => {
900+ | FilterFocus :: Partitions
901+ | FilterFocus :: ApplyButton
902+ | FilterFocus :: CancelButton => {
844903 self . focus = FilterFocus :: QoS ;
845904 }
846905 _ => { }
0 commit comments