From 98068cb86cf8a63f840c2c8b68f6f3cfe6f1394c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Wed, 30 Aug 2023 10:02:25 +0200 Subject: [PATCH] (core) Hiding expand button if there is single widget on a page Summary: Expand button on a page with a single widget seems pointless and presents a bad UX when embedded. Test Plan: new tests Reviewers: georgegevoian Reviewed By: georgegevoian Subscribers: georgegevoian Differential Revision: https://phab.getgrist.com/D4020 --- app/client/ui/ViewSectionMenu.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/client/ui/ViewSectionMenu.ts b/app/client/ui/ViewSectionMenu.ts index 70b375e5..d8d8b8f2 100644 --- a/app/client/ui/ViewSectionMenu.ts +++ b/app/client/ui/ViewSectionMenu.ts @@ -55,12 +55,22 @@ export function viewSectionMenu( const save = () => { doSave(docModel, viewSection).catch(reportError); }; const revert = () => doRevert(viewSection); + // If this section is the only one in the view (or view temporary has no sections at all). + const singleVisible = Computed.create(owner, (use) => { + const view = use(viewSection.view); + const sections = use(use(view.viewSections).getObservable()); + const expanded = sections.filter(s => use(s.isCollapsed) === false).length; + return expanded === 1 || !expanded; // single, or no sections at all (temporary). + }); + // Should we show expand icon. const showExpandIcon = Computed.create(owner, (use) => { return !use(isNarrowScreenObs()) // not on narrow screens && use(gristDoc.maximizedSectionId) !== use(viewSection.id) // not in when we are maximized && use(gristDoc.externalSectionId) !== use(viewSection.id) // not in when we are external - && !use(viewSection.isRaw); // not in raw mode + && !use(viewSection.isRaw) // not in raw mode + && !use(singleVisible) // not in single section + ; }); return [