Retain contextual ribbon when maximising PWA workspaces

This commit is contained in:
Nick Beckley 2026-11-03 20:35:36 +00:00
parent 79c4fd22bc
commit d7ae6e2096
7 changed files with 97 additions and 19 deletions

View File

@ -68,3 +68,11 @@ Added one lifecycle-managed resizing mechanism to the existing workspace surface
Verification: solution build passed (0 warnings/errors); new browser suite passed across all three workspace grids, four theme settings, keyboard/pointer resizing, independent widths, persisted reload restoration in Maps/Relationships, reset, smaller viewports, no text selection/canvas pointer events, unchanged map document. Floor Plans uses its production CSS and shared resizing code in an isolated grid fixture; full editor verification remains pending. Existing comprehensive Relationships browser suite passed (75 characters, 300 scenes, search, drag/drop, editing, timeline, persistence, responsive layout, PWA menu). Fixed an initial viewport overflow caught by that suite using CSS-relative divider placement. B4 commit: a348777.
Next: C2 preserve contextual ribbon while maximising all three workspaces; then broader audits.
### C2/C4 — Consistent PWA maximisation and full-editor verification
All three editors now share PWA shell handling: hide the titlebar/quick access and section-tab heading, retain the contextual ribbon, place the maximised surface below its measured bounds, and keep the Restore workspace command available. Browser maximisation and Maps separate-window handling retain their existing behaviour. Header resize observation is disposed with the workspace lifecycle.
Added a real Floor Plans editor fixture with its production Razor script section, floor and block; expanded panel tests from the isolated Floor Plans grid to the full editor. Verification: build passed (0 warnings/errors); full-editor panel tests passed across Maps, Relationships and Floor Plans in browser, normal PWA and maximised PWA, four theme settings, narrow viewports, saved-width restoration, keyboard/pointer resize and reset. Maximise/restore regression passed for all three editors in browser/PWA and four themes, including shell visibility, ribbon Restore command, canvas bounds and preserved map document/relationship pan and zoom/floor block state. Existing Maps browser/PWA author workflow regression passed. Full regression harness rerun in progress. C1 commit: 79c4fd2.
Explicit B/C improvements are implemented and committed. Next: targeted broader UX/functional/security/public-site audits and repairs; Development deployment after final checks and background-work safety verification.

View File

@ -13,7 +13,7 @@ const base=process.env.PD_MAPS_TEST_URL||'http://127.0.0.1:5246';
const canvas=page.locator('#mapsCanvas');
async function sourceClick(id){
const proxy=page.locator(`[data-pwa-context-controls] [data-command-identity="handler:${id}"]`);
if(pwa&&await proxy.count()&&!await page.locator('#mapsApp').evaluate(n=>n.classList.contains('pd-workspace-maximised'))){
if(pwa&&await proxy.count()){
const menu=proxy.locator('xpath=ancestor::details[1]');
if(await menu.count()&&await menu.getAttribute('data-compact')==='true'&&await menu.getAttribute('open')===null)await menu.locator(':scope > summary').click();
await proxy.click();

View File

@ -0,0 +1,38 @@
const {chromium}=require('playwright');
const assert=require('node:assert/strict');
(async()=>{
const browser=await chromium.launch();
try {
for(const pwa of [false,true]) for(const theme of ['modern-light','modern-dark','warm-light','warm-dark']) {
const context=await browser.newContext({viewport:{width:1600,height:1000}});
if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));
const page=await context.newPage(),errors=[];page.on('pageerror',e=>errors.push(e.message));
for(const [name,appId,buttonId] of [['maps','mapsApp','mapsMaximise'],['relationships','rwApp','rwMaximise'],['floorplans',null,'floorPlanMaximise']]) {
await page.goto(`http://127.0.0.1:5238/fixture?page=${name}`);
await page.waitForFunction(id=>document.getElementById(id)?.getAttribute('aria-pressed')!==null,buttonId);
await page.evaluate(theme=>document.documentElement.dataset.appTheme=theme,theme);
await page.waitForFunction(()=>!!(window.PlotDirectorMapWorkspace||window.PlotDirectorRelationshipWorkspace||document.querySelector('[data-floor-plan-initialized=true]')));
const app = page.locator(appId ? '#'+appId : '[data-floor-plan-workspace]');
const before=await app.evaluate(node=>node.getBoundingClientRect().height);
const state=await page.evaluate(()=>window.PlotDirectorMapWorkspace?JSON.stringify(window.PlotDirectorMapWorkspace.document):window.PlotDirectorRelationshipWorkspace?JSON.stringify({pan:window.PlotDirectorRelationshipWorkspace.cy.pan(),zoom:window.PlotDirectorRelationshipWorkspace.cy.zoom()}):JSON.stringify([...document.querySelectorAll('[data-block]')].map(node=>({...node.dataset}))));
await page.locator('#'+buttonId).evaluate(button=>button.click());
await page.waitForFunction(id=>document.getElementById(id).getAttribute('aria-pressed')==='true',buttonId);
assert.equal(await app.evaluate(node=>node.classList.contains('pd-workspace-chrome-free')), !pwa&&name!=='relationships');
if(pwa) {
assert(await page.locator('.pd-titlebar').isHidden());assert(await page.locator('.pd-ribbon-heading').isHidden());
assert(await page.locator('[data-pwa-context-controls]').isVisible());
const restore=page.locator('[data-pwa-context-controls]').getByRole('button',{name:'Restore workspace',exact:true,includeHidden:true});
assert.equal(await restore.count(),1,'Context ribbon keeps restore command');
const bounds=await app.boundingBox(),header=await page.locator('.pd-application-header').boundingBox();
assert.ok(bounds.y>=header.y+header.height,'canvas stays below contextual ribbon');
}
assert.ok(await app.evaluate(node=>node.getBoundingClientRect().height)>before,'maximise expands workspace');
await page.locator('#'+buttonId).evaluate(button=>button.click());
if(pwa){assert(await page.locator('.pd-titlebar').isVisible());assert(await page.locator('.pd-ribbon-heading').isVisible());}
assert.equal(await page.evaluate(()=>window.PlotDirectorMapWorkspace?JSON.stringify(window.PlotDirectorMapWorkspace.document):window.PlotDirectorRelationshipWorkspace?JSON.stringify({pan:window.PlotDirectorRelationshipWorkspace.cy.pan(),zoom:window.PlotDirectorRelationshipWorkspace.cy.zoom()}):JSON.stringify([...document.querySelectorAll('[data-block]')].map(node=>({...node.dataset})))),state,'editing state survives maximise and restore');
}
assert.deepEqual(errors,[]);await context.close();
}
console.log('PASS maximise/restore preserves PWA contextual ribbon, shell restoration and editing state for Maps/Relationships/Floor Plans in four themes and browser/PWA modes');
}finally{await browser.close();}
})().catch(error=>{console.error(error);process.exitCode=1;});

View File

@ -1,24 +1,17 @@
const { chromium } = require('playwright');
const assert = require('node:assert/strict');
const path = require('node:path');
(async () => {
const browser = await chromium.launch();
try {
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
for (const pwa of [false, true]) {
const context = await browser.newContext({ viewport: { width: 1600, height: 1000 } });
if (pwa) await context.addInitScript(() => Object.defineProperty(navigator, 'standalone', { value: true }));
const page = await context.newPage();
const errors=[]; page.on('pageerror', error => errors.push(error.message));
for (const theme of ['modern-light','modern-dark','warm-light','warm-dark']) {
for (const [name, layout, left, right] of [['maps','.maps-body','.maps-library','.maps-details'],['relationships','.rw-board','.rw-navigation','.rw-rail'],['floorplans','.floor-plan-layout','.floor-plan-build','.floor-plan-inspector']]) {
if (name === 'floorplans') {
await page.goto('http://127.0.0.1:5238/fixture?page=maps');
await page.setContent(`<html data-app-theme="${theme}"><body><section data-floor-plan-workspace style="height:600px"><button id="max">Maximise</button><div class="floor-plan-layout"><aside class="floor-plan-build">Build</aside><main>Canvas</main><aside class="floor-plan-inspector">Inspector</aside></div></section></body></html>`);
await page.addStyleTag({path:path.resolve('PlotLine/wwwroot/css/floor-plan-workspace.css')});
await page.addStyleTag({path:path.resolve('PlotLine/wwwroot/css/workspace-surface.css')});
await page.addScriptTag({path:path.resolve('PlotLine/wwwroot/js/workspace-surface.js')});
await page.evaluate(()=>window.PlotDirectorWorkspaceSurface.attach(document.querySelector('section'),document.querySelector('#max')));
} else {
await page.goto(`http://127.0.0.1:5238/fixture?page=${name}`);
await page.evaluate(theme => document.documentElement.dataset.appTheme=theme,theme);
}
await page.goto(`http://127.0.0.1:5238/fixture?page=${name}`);
await page.evaluate(theme => document.documentElement.dataset.appTheme=theme,theme);
await page.evaluate(() => {
window.canvasPointerEvents = 0;
document.querySelector('.maps-centre, .rw-centre, main')?.addEventListener('pointerdown', () => window.canvasPointerEvents++);
@ -41,17 +34,25 @@ const path = require('node:path');
assert.ok(saved.left && saved.right);
assert.equal(await page.evaluate(() => window.canvasPointerEvents), 0, 'Divider must not begin canvas dragging');
if (mapBefore) assert.equal(await page.evaluate(() => JSON.stringify(window.PlotDirectorMapWorkspace.document)), mapBefore, 'Panel resize preserves map objects');
if (name !== 'floorplans') {
{
await page.reload();
await leftHandle.waitFor();
assert.ok(Math.abs(await l.evaluate(node => node.getBoundingClientRect().width) - saved.left) < 2, name + ' restored left width');
assert.ok(Math.abs(await r.evaluate(node => node.getBoundingClientRect().width) - saved.right) < 2, name + ' restored right width');
}
const maximise = page.locator(name === 'maps' ? '#mapsMaximise' : name === 'relationships' ? '#rwMaximise' : '#floorPlanMaximise');
await maximise.evaluate(button => button.click());
const maxRight = await r.evaluate(node => node.getBoundingClientRect().width);
await rightHandle.press('ArrowLeft');
assert.ok(Math.abs(await r.evaluate(node => node.getBoundingClientRect().width) - maxRight - 10) < 2, name + ' maximised resize');
await maximise.evaluate(button => button.click());
await leftHandle.press('Home');
await page.setViewportSize({width:700,height:900});assert.equal(await leftHandle.isVisible(),false);
await page.setViewportSize({width:1600,height:1000});
}
}
assert.deepEqual(errors,[]);console.log('PASS independent keyboard/pointer panel resizing, persistence, reset and small viewports across workspace grids and four themes');
assert.deepEqual(errors,[]); await context.close();
}
console.log('PASS independent keyboard/pointer panel resizing, persistence, reset and small viewports across full editors, four themes and browser/normal PWA/maximised PWA');
} finally {await browser.close();}
})().catch(error=>{console.error(error);process.exitCode=1;});

View File

@ -191,6 +191,13 @@ internal static class ToolbarBrowserHost
data["ApplicationAppearance"] = appearance;
var temp = new TempDataDictionary(context, context.RequestServices.GetRequiredService<ITempDataProvider>());
await view.View.RenderAsync(new ViewContext(action, view.View, data, temp, writer, new HtmlHelperOptions()));
if (name == "FloorPlans/Edit" && view.View is Microsoft.AspNetCore.Mvc.Razor.RazorView razorView
&& razorView.RazorPage.SectionWriters.TryGetValue("Scripts", out var scripts))
{
writer.Write("<script src='/lib/jquery/dist/jquery.min.js'></script>");
razorView.RazorPage.ViewContext.Writer = writer;
await scripts();
}
return writer.ToString();
}
@ -368,6 +375,17 @@ internal static class ToolbarBrowserHost
});
surface += "<script src='/js/application-dialogs.js'></script><script src='/js/workspace-surface.js'></script><script src='/js/maps-symbols.js'></script><script src='/js/workspace-bridge.js'></script><script src='/js/maps-engine.js'></script><script src='/js/maps-appearance-engine.js'></script><script src='/js/maps-workspace.js'></script><script src='/js/maps-appearance.js'></script><script src='/js/maps-story-engine.js'></script><script src='/js/maps-story.js'></script>";
}
if (context.Request.Query["page"] == "floorplans")
{
route.Values["controller"] = "FloorPlans"; route.Values["action"] = "Edit";
model.ActiveSection = "Floor Plans";
surface = await Render("FloorPlans/Edit", new FloorPlanEditorViewModel {
Project = model.Project!,
FloorPlan = new() { ProjectID = 7, FloorPlanID = 31, Name = "Fixture building" },
Floors = [new() { FloorPlanFloorID = 41, FloorPlanID = 31, Name = "Ground floor" }],
Blocks = [new() { FloorPlanBlockID = 51, FloorPlanFloorID = 41, LocationName = "Study", X = 2, Y = 2, WidthCells = 3, HeightCells = 2 }]
});
}
surface += await Render("Shared/_ConfirmationDialog");
var initialTheme = appearance.ThemeKey ?? "warm-light";
var appearanceScript = "<script>window.plotdirectorAppearance=" + System.Text.Json.JsonSerializer.Serialize(new { theme = initialTheme, migrate = false, collapsed = appearance.RibbonCollapsed }) + ";</script>";

View File

@ -1,4 +1,4 @@
.pd-workspace-maximised{position:fixed!important;inset:4px!important;margin:0!important;width:auto!important;height:auto!important;max-width:none!important;z-index:1040!important}html:not([data-standalone=true]):has(.pd-workspace-maximised) .pd-application-header{visibility:hidden}.pd-workspace-maximised:focus{outline:none}html[data-standalone=true] .pd-workspace-maximised.rw-app{top:var(--rw-ribbon-bottom,4px)!important;z-index:1010!important}.pd-detached-shell{margin:0;padding:4px;min-height:100dvh}.pd-detached-shell .maps-app{height:calc(100dvh - 8px)!important;min-height:350px}.pd-detached-shell .maps-toolbar{display:flex!important}.pd-detached-shell .maps-story-toolbar:not([hidden]){display:flex!important}.pd-detached-shell #mapsMaximise,.pd-detached-shell #mapsDetach{display:none!important}.pd-workspace-command-catalog{display:none!important}
.pd-workspace-maximised{position:fixed!important;inset:4px!important;margin:0!important;width:auto!important;height:auto!important;max-width:none!important;z-index:1040!important}html:not([data-standalone=true]):has(.pd-workspace-maximised) .pd-application-header{visibility:hidden}.pd-workspace-maximised:focus{outline:none}html[data-standalone=true] .pd-workspace-maximised{top:var(--workspace-ribbon-bottom,4px)!important;z-index:1010!important;min-height:0!important}.pd-detached-shell{margin:0;padding:4px;min-height:100dvh}.pd-detached-shell .maps-app{height:calc(100dvh - 8px)!important;min-height:350px}.pd-detached-shell .maps-toolbar{display:flex!important}.pd-detached-shell .maps-story-toolbar:not([hidden]){display:flex!important}.pd-detached-shell #mapsMaximise,.pd-detached-shell #mapsDetach{display:none!important}.pd-workspace-command-catalog{display:none!important}
/* Keep the shared workspace surface and its controls available when the ribbon is hidden. */
html:has(.pd-workspace-chrome-free) .pd-application-header{visibility:hidden!important;pointer-events:none}
@ -21,3 +21,7 @@ html.pd-panel-resizing, html.pd-panel-resizing * { cursor:col-resize!important;
.pd-panel-divider[data-panel-side=left] { left:calc(var(--workspace-left) - 4px); }
.pd-panel-divider[data-panel-side=right] { right:calc(var(--workspace-right) - 4px); }
.rw-board.palettes-hidden .pd-panel-divider[data-panel-side=left] { display:none; }
/* Retain the contextual commands while recovering the outer PWA shell space. */
html[data-standalone=true]:has(.pd-workspace-maximised) .pd-application-header .pd-titlebar,
html[data-standalone=true]:has(.pd-workspace-maximised) .pd-application-header .pd-ribbon-heading { display:none; }

View File

@ -81,9 +81,18 @@
window.PlotDirectorWorkspaceSurface={attach(app,button,{className='pd-workspace-maximised',onChange=()=>{},allowPwa=false,hideChrome=false}={}){
const lifecycle = new AbortController(), listenerOptions = {signal:lifecycle.signal};
const disposePanels = panels(app, lifecycle.signal);
function set(active){app.classList.toggle(className,active);app.classList.toggle('pd-workspace-chrome-free',active&&hideChrome);app.classList.toggle('pd-workspace-maximised',active);button.setAttribute('aria-pressed',String(active));const label=active?'Restore workspace':'Maximise workspace';button.setAttribute('aria-label',label);button.title=label;button.dataset.ribbonIcon=active?'restore-workspace':'maximise';const text=button.querySelector('[data-workspace-caption]');if(text)text.textContent=label;onChange(active);window.dispatchEvent(new CustomEvent('pd-workspace-resize'));}
const isPwa = () => document.documentElement.dataset.standalone === 'true' || !!window.PlotDirectorPwa?.standalone;
const syncShell = () => {
const active = app.classList.contains(className);
app.classList.toggle('pd-workspace-chrome-free', active && hideChrome && !isPwa());
if (active && isPwa()) app.style.setProperty('--workspace-ribbon-bottom', `${(document.querySelector('.pd-application-header')?.getBoundingClientRect().bottom || 0) + 4}px`);
};
const headerObserver = new ResizeObserver(syncShell);
const header = document.querySelector('.pd-application-header');
if (header) headerObserver.observe(header);
function set(active){app.classList.toggle(className,active);app.classList.toggle('pd-workspace-maximised',active);syncShell();button.setAttribute('aria-pressed',String(active));const label=active?'Restore workspace':'Maximise workspace';button.setAttribute('aria-label',label);button.title=label;button.dataset.ribbonIcon=active?'restore-workspace':'maximise';const text=button.querySelector('[data-workspace-caption]');if(text)text.textContent=label;onChange(active);window.dispatchEvent(new CustomEvent('pd-workspace-resize'));}
button.addEventListener('click',()=>set(!app.classList.contains(className)),listenerOptions);
document.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&app.classList.contains(className)&&!document.querySelector('dialog[open],.modal.show,.pd-context-popup')&&!app.querySelector('.rw-menu[open]'))set(false);},listenerOptions);
const sync=()=>{button.hidden=!allowPwa&&(!!window.PlotDirectorPwa?.standalone||document.documentElement.dataset.workspaceDetached==='true');};sync();window.addEventListener('plotdirector:pwa-mode-changed',sync,listenerOptions);window.matchMedia('(display-mode: standalone)').addEventListener('change',sync,listenerOptions);return {set,dispose(){disposePanels();lifecycle.abort();},get active(){return app.classList.contains(className);}};
const sync=()=>{syncShell();button.hidden=!allowPwa&&(!!window.PlotDirectorPwa?.standalone||document.documentElement.dataset.workspaceDetached==='true');};sync();window.addEventListener('plotdirector:pwa-mode-changed',sync,listenerOptions);window.matchMedia('(display-mode: standalone)').addEventListener('change',sync,listenerOptions);return {set,dispose(){headerObserver.disconnect();disposePanels();lifecycle.abort();},get active(){return app.classList.contains(className);}};
}};
})();