Skip to content

Commit 6b0be08

Browse files
AlinaVarkkiDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Update Devtools Setting for Navigation and Make it sync with the one in the dialog
The state of the navigation radio buttons was only updated when they were initiated. Instead, update the checked radio button every time the dialog is open since it can also be updated from the Devtools Settings. Bug: 313757601 Change-Id: I36134604553a53b9d7aa6eb19bcd0067c53a9f34 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6084697 Commit-Queue: Jack Franklin <[email protected]> Auto-Submit: Alina Varkki <[email protected]> Commit-Queue: Alina Varkki <[email protected]> Reviewed-by: Jack Franklin <[email protected]>
1 parent 7eaf391 commit 6b0be08

File tree

2 files changed

+41
-25
lines changed

2 files changed

+41
-25
lines changed

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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[] {

front_end/ui/legacy/components/perf_ui/perf_ui-meta.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ import type * as PerfUI from './perf_ui.js';
1111

1212
const UIStrings = {
1313
/**
14-
*@description Title of a setting under the Performance category in Settings
14+
*@description Title of a setting under the Performance category in Settings.
15+
* Selected navigation allows switching between 2 different sets of shortcuts
16+
* and actions (like zoom on scroll or crtl/cmd + scroll) for navigating the performance panel.
1517
*/
16-
flamechartMouseWheelAction: 'Flamechart mouse wheel action:',
18+
flamechartSelectedNavigation: 'Flamechart navigation:',
1719
/**
18-
*@description The action to scroll
20+
*@description Modern navigation option in the Performance Panel.
1921
*/
20-
scroll: 'Scroll',
22+
modern: 'Modern',
2123
/**
22-
*@description Text for zooming in
24+
*@description Classic navigation option in the Performance Panel.
2325
*/
24-
zoom: 'Zoom',
26+
classic: 'Classic',
2527
/**
2628
* @description Title of a setting under the Memory category in Settings. Live memory is memory
2729
* that is still in-use by the program (not dead). Allocation of live memory is when the program
@@ -69,19 +71,19 @@ UI.ActionRegistration.registerActionExtension({
6971
Common.Settings.registerSettingExtension({
7072
category: Common.Settings.SettingCategory.PERFORMANCE,
7173
storageType: Common.Settings.SettingStorageType.SYNCED,
72-
title: i18nLazyString(UIStrings.flamechartMouseWheelAction),
74+
title: i18nLazyString(UIStrings.flamechartSelectedNavigation),
7375
settingName: 'flamechart-selected-navigation',
7476
settingType: Common.Settings.SettingType.ENUM,
7577
defaultValue: 'classic',
7678
options: [
7779
{
78-
title: i18nLazyString(UIStrings.scroll),
79-
text: i18nLazyString(UIStrings.scroll),
80+
title: i18nLazyString(UIStrings.modern),
81+
text: i18nLazyString(UIStrings.modern),
8082
value: 'modern',
8183
},
8284
{
83-
title: i18nLazyString(UIStrings.zoom),
84-
text: i18nLazyString(UIStrings.zoom),
85+
title: i18nLazyString(UIStrings.classic),
86+
text: i18nLazyString(UIStrings.classic),
8587
value: 'classic',
8688
},
8789
],

0 commit comments

Comments
 (0)