@@ -459,6 +459,12 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
459459
460460 #eventToRelatedInsights: TimelineComponents . RelatedInsightChips . EventToRelatedInsightsMap = new Map ( ) ;
461461 #shortcutsDialog: Dialogs . ShortcutDialog . ShortcutDialog = new Dialogs . ShortcutDialog . ShortcutDialog ( ) ;
462+ /**
463+ * Navigation radio buttons located in the shortcuts dialog.
464+ */
465+ #navigationRadioButtons = document . createElement ( 'form' ) ;
466+ #modernNavRadioButton = UI . UIUtils . createRadioLabel ( 'flamechart-selected-navigation' , 'Modern' ) ;
467+ #classicNavRadioButton = UI . UIUtils . createRadioLabel ( 'flamechart-selected-navigation' , 'Classic' ) ;
462468
463469 #onMainEntryHovered: ( event : Common . EventTarget . EventTargetEvent < number > ) => void ;
464470
@@ -1106,37 +1112,45 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
11061112 }
11071113
11081114 if ( Root . Runtime . experiments . isEnabled ( Root . Runtime . ExperimentName . TIMELINE_ALTERNATIVE_NAVIGATION ) ) {
1109- this . #shortcutsDialog. prependElement ( this . #getNavigationSetting( ) ) ;
1115+ this . #setupNavigationSetting( ) ;
1116+ this . #shortcutsDialog. prependElement ( this . #navigationRadioButtons) ;
11101117 const dialogToolbarItem = new UI . Toolbar . ToolbarItem ( this . #shortcutsDialog) ;
11111118 this . panelRightToolbar . appendToolbarItem ( dialogToolbarItem ) ;
1119+ // The setting could have been changed from the Devtools Settings. Therefore, we
1120+ // need to update the radio buttons selection when the dialog is open.
1121+ this . #shortcutsDialog. addEventListener ( 'click' , this . #updateNavigationSettingSelection. bind ( this ) ) ;
11121122 }
11131123 }
11141124
1115- #getNavigationSetting ( ) : HTMLElement {
1125+ #setupNavigationSetting ( ) : HTMLElement {
11161126 const currentNavSetting = Common . Settings . moduleSetting ( 'flamechart-selected-navigation' ) . get ( ) ;
11171127 this . #shortcutsDialog. data = { shortcuts : this . #getShortcutsInfo( currentNavSetting === 'classic' ) } ;
11181128
1119- const navigationRadioButtons = document . createElement ( 'form' ) ;
1120- navigationRadioButtons . classList . add ( 'nav-radio-buttons' ) ;
1121- UI . ARIAUtils . markAsRadioGroup ( navigationRadioButtons ) ;
1122- const modernNavRadioButton = UI . UIUtils . createRadioLabel (
1123- 'flamechart-selected-navigation' , 'Modern' , /* checked */ currentNavSetting === 'modern' ) ;
1129+ this . #navigationRadioButtons. classList . add ( 'nav-radio-buttons' ) ;
1130+ UI . ARIAUtils . markAsRadioGroup ( this . #navigationRadioButtons) ;
11241131 // Change EventListener is only triggered when the radio button is selected
1125- modernNavRadioButton . radioElement . addEventListener ( 'change' , ( ) => {
1132+ this . # modernNavRadioButton. radioElement . addEventListener ( 'change' , ( ) => {
11261133 this . #shortcutsDialog. data = { shortcuts : this . #getShortcutsInfo( /* isNavClassic */ false ) } ;
11271134 Common . Settings . moduleSetting ( 'flamechart-selected-navigation' ) . set ( 'modern' ) ;
11281135 } ) ;
1129- const classicNavRadioButton = UI . UIUtils . createRadioLabel (
1130- 'flamechart-selected-navigation' , 'Classic' , /* checked */ currentNavSetting === 'classic' ) ;
1131- classicNavRadioButton . radioElement . addEventListener ( 'change' , ( ) => {
1136+ this . #classicNavRadioButton. radioElement . addEventListener ( 'change' , ( ) => {
11321137 this . #shortcutsDialog. data = { shortcuts : this . #getShortcutsInfo( /* isNavClassic */ true ) } ;
11331138 Common . Settings . moduleSetting ( 'flamechart-selected-navigation' ) . set ( 'classic' ) ;
11341139 } ) ;
11351140
1136- navigationRadioButtons . appendChild ( modernNavRadioButton ) ;
1137- navigationRadioButtons . appendChild ( classicNavRadioButton ) ;
1141+ this . #navigationRadioButtons. appendChild ( this . #modernNavRadioButton) ;
1142+ this . #navigationRadioButtons. appendChild ( this . #classicNavRadioButton) ;
1143+
1144+ return this . #navigationRadioButtons;
1145+ }
11381146
1139- return navigationRadioButtons ;
1147+ #updateNavigationSettingSelection( ) : void {
1148+ const currentNavSetting = Common . Settings . moduleSetting ( 'flamechart-selected-navigation' ) . get ( ) ;
1149+ if ( currentNavSetting === 'classic' ) {
1150+ this . #classicNavRadioButton. radioElement . checked = true ;
1151+ } else if ( currentNavSetting === 'modern' ) {
1152+ this . #modernNavRadioButton. radioElement . checked = true ;
1153+ }
11401154 }
11411155
11421156 #getShortcutsInfo( isNavClassic : boolean ) : Dialogs . ShortcutDialog . Shortcut [ ] {
0 commit comments