Skip to content

Commit

Permalink
Fix top bar visibility not picking up settings overrides (#6833)
Browse files Browse the repository at this point in the history
* The header part reflects both user preference and default settings overrides.

* Toggle 'Show Header' turns off the automatic adjustment.
  • Loading branch information
yumyumqing committed May 2, 2023
1 parent 7c3c992 commit 6604839
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/application-extension/schema/top.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
"title": "Top Bar Visibility",
"description": "Whether to show the top bar or not",
"default": true
},
"adjustToScreen": {
"type": "boolean",
"title": "Automatic Top Bar Visibility",
"description": "Whether to automatically adjust top bar visibility according to screen size, overriding above visible setting",
"default": true
}
},
"additionalProperties": false,
Expand Down
21 changes: 16 additions & 5 deletions packages/application-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,20 +483,31 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
top.setHidden(top.isVisible);
if (settingRegistry) {
void settingRegistry.set(pluginId, 'visible', top.isVisible);
// turn off 'adjustToScreen' if user manually toggle 'Show Header'
void settingRegistry.set(pluginId, 'adjustToScreen', false);
}
},
isToggled: () => top.isVisible,
});

let settingsOverride = false;
let noAdjust = false;

if (settingRegistry) {
const loadSettings = settingRegistry.load(pluginId);
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
const visible = settings.get('visible').composite;
// 'visible' property from user preferences or default settings
let visible = settings.get('visible').composite;
if (settings.user.visible !== undefined) {
settingsOverride = true;
top.setHidden(!visible);
visible = settings.user.visible;
}
top.setHidden(!visible);
// 'adjustToScreen' property from user preferences or default settings
let adjustToScreen = settings.get('adjustToScreen').composite;
if (settings.user.adjustToScreen !== undefined) {
adjustToScreen = settings.user.adjustToScreen;
}
if (!adjustToScreen) {
noAdjust = true;
}
};

Expand All @@ -517,7 +528,7 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
}

const onChanged = (): void => {
if (settingsOverride) {
if (noAdjust) {
return;
}
if (app.format === 'desktop') {
Expand Down

0 comments on commit 6604839

Please sign in to comment.