From d9abf871aff00736cf1ac3628f578aa678d52090 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Thu, 5 Nov 2020 16:40:03 +0300 Subject: [PATCH] Toggling .mouse-intent Signed-off-by: Alex Andreev --- src/renderer/components/layout/main-layout.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/renderer/components/layout/main-layout.tsx b/src/renderer/components/layout/main-layout.tsx index 67c6c08bce..2c3c718d65 100755 --- a/src/renderer/components/layout/main-layout.tsx +++ b/src/renderer/components/layout/main-layout.tsx @@ -38,6 +38,18 @@ export class MainLayout extends React.Component { (sidebarWidth) => this.storage.merge({ sidebarWidth }) ); + componentDidMount() { + // Toggling .mouse-intent class if mouse or keyboard using in the dashboard + // This allows to remove focus styling to elements when mouse is used + window.addEventListener("click", (evt) => { + if (!evt.detail) return; // No mouse used (e.g. hitted spacebar on button) + document.body.classList.add("mouse-intent"); + }) + window.addEventListener("keydown", (evt) => { + document.body.classList.remove("mouse-intent"); + }) + } + toggleSidebar = () => { this.isPinned = !this.isPinned; this.isAccessible = false;