Skip to content

Commit 22b5f14

Browse files
authored
Fix top bar visibility not picking up settings overrides (#6833) (#6836)
* Make 'visible' enum type and pick up both default and user settings.
1 parent 7c3c992 commit 22b5f14

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

packages/application-extension/schema/top.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
},
1919
"properties": {
2020
"visible": {
21-
"type": "boolean",
21+
"type": "string",
22+
"enum": ["yes", "no", "automatic"],
2223
"title": "Top Bar Visibility",
23-
"description": "Whether to show the top bar or not",
24-
"default": true
24+
"description": "Whether to show the top bar or not, yes for always showing, no for always not showing, automatic for adjusting to screen size",
25+
"default": "automatic"
2526
}
2627
},
2728
"additionalProperties": false,

packages/application-extension/src/index.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,22 +482,29 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
482482
execute: () => {
483483
top.setHidden(top.isVisible);
484484
if (settingRegistry) {
485-
void settingRegistry.set(pluginId, 'visible', top.isVisible);
485+
void settingRegistry.set(
486+
pluginId,
487+
'visible',
488+
top.isVisible ? 'yes' : 'no'
489+
);
486490
}
487491
},
488492
isToggled: () => top.isVisible,
489493
});
490494

491-
let settingsOverride = false;
495+
let adjustToScreen = false;
492496

493497
if (settingRegistry) {
494498
const loadSettings = settingRegistry.load(pluginId);
495499
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
496-
const visible = settings.get('visible').composite;
500+
// 'visible' property from user preferences or default settings
501+
let visible = settings.get('visible').composite;
497502
if (settings.user.visible !== undefined) {
498-
settingsOverride = true;
499-
top.setHidden(!visible);
503+
visible = settings.user.visible;
500504
}
505+
top.setHidden(visible === 'no');
506+
// adjust to screen from user preferences or default settings
507+
adjustToScreen = visible === 'automatic';
501508
};
502509

503510
Promise.all([loadSettings, app.restored])
@@ -517,7 +524,7 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
517524
}
518525

519526
const onChanged = (): void => {
520-
if (settingsOverride) {
527+
if (!adjustToScreen) {
521528
return;
522529
}
523530
if (app.format === 'desktop') {

0 commit comments

Comments
 (0)