From 65417f75b812a3259f3e4b3d57080af7bf604f10 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Fri, 18 Sep 2026 01:42:07 +0100 Subject: [PATCH] Enhance Dashboard Navigation with New Modal Visibility Handling and Styling - Introduced state management for modal visibility in the DashboardNavigation component to improve user interaction and layout responsiveness. - Added new CSS styles for dashboard navigation elements, including transitions and layout adjustments for better visual clarity. - Refactored the rendering logic to conditionally display navigation elements based on modal visibility, enhancing the overall user experience. --- assets/stylesheets/App.css | 36 ++++++ .../Dashboard/common/DashboardNavigation.jsx | 117 ++++++++++++------ 2 files changed, 117 insertions(+), 36 deletions(-) diff --git a/assets/stylesheets/App.css b/assets/stylesheets/App.css index dfedae6e..bfce1c54 100644 --- a/assets/stylesheets/App.css +++ b/assets/stylesheets/App.css @@ -112,6 +112,42 @@ --webkit-user-select: none; } +.dashboard-navigation-center { + position: relative; + flex: 1; + min-width: 0; + align-self: stretch; + display: flex; + align-items: center; +} + +.dashboard-navigation-fade { + opacity: 1; + visibility: visible; + transition: + opacity 0.2s ease, + visibility 0.2s ease; +} + +.dashboard-navigation-fade-hidden { + opacity: 0; + visibility: hidden; + pointer-events: none; +} + +.dashboard-navigation-window-title { + position: absolute; + inset: 0; + display: flex; + align-items: center; + padding-left: 14px; + font-size: 14px; + pointer-events: none; + user-select: none; + -webkit-user-select: none; + border-bottom: 1px solid var(--color-header-border); +} + .electron-navigation-leading, .electron-navigation-trailing { align-self: stretch; diff --git a/src/components/Dashboard/common/DashboardNavigation.jsx b/src/components/Dashboard/common/DashboardNavigation.jsx index 92b3eb11..6168ca28 100644 --- a/src/components/Dashboard/common/DashboardNavigation.jsx +++ b/src/components/Dashboard/common/DashboardNavigation.jsx @@ -216,6 +216,7 @@ const DashboardNavigation = () => { : mainMenuItems.map((item) => ({ ...item, label: undefined })) const [userPopoverOpen, setUserPopoverOpen] = useState(false) + const [anyModalVisible, setAnyModalVisible] = useState(false) const userPopoverContent = ( setUserPopoverOpen(false)} /> @@ -255,7 +256,48 @@ const DashboardNavigation = () => { const showDesktopLogo = !isElectron && !isMobile const showMobileLogo = !isElectron && isMobile - const showControls = !isElectron || authenticated + useEffect(() => { + const isModalWrapVisible = (node) => { + if (!(node instanceof Element)) return false + if (node.getAttribute('aria-hidden') === 'true') return false + const style = window.getComputedStyle(node) + return ( + style.display !== 'none' && + style.visibility !== 'hidden' && + style.pointerEvents !== 'none' + ) + } + + const updateModalVisibility = () => { + const wraps = document.querySelectorAll('.ant-modal-wrap') + setAnyModalVisible(Array.from(wraps).some(isModalWrapVisible)) + } + + let frameId = 0 + const scheduleUpdate = () => { + if (frameId) return + frameId = window.requestAnimationFrame(() => { + frameId = 0 + updateModalVisibility() + }) + } + + updateModalVisibility() + const observer = new MutationObserver(scheduleUpdate) + observer.observe(document.body, { + childList: true, + subtree: true, + attributes: true, + attributeFilter: ['style', 'class', 'aria-hidden'] + }) + + return () => { + observer.disconnect() + if (frameId) window.cancelAnimationFrame(frameId) + } + }, []) + + const showControls = (!isElectron || authenticated) && !anyModalVisible const menu = ( { ) + const windowTitle = ( + + Farm Control + + ) + const navigationContents = ( {navigationLeading} -
- {showControls && !isMobile ? ( - +
+ {!isMobile ? ( + {menu} ) : null} - {!showControls && ( - - Farm Control - - )} + {windowTitle}
{navigationTrailing}
@@ -473,11 +522,7 @@ const DashboardNavigation = () => { className={`electron-navigation-wrapper ${electronDragClass}`} style={{ lineHeight: '40px', padding: '0 2px 0 2px' }} > - + {navigationLeading} {showControls && !isMobile ? menu : null} {showControls && !isMobile ? ( @@ -491,21 +536,21 @@ const DashboardNavigation = () => { }} /> ) : null} - {!showControls ? ( - - Farm Control - - ) : null} - {showControls && !isMobile ? : null} +
+ {!isMobile ? ( +
+ +
+ ) : null} + {windowTitle} +
{navigationTrailing}