From 5b99d8dd112554d2fe1842af5d3ed5039c1965d7 Mon Sep 17 00:00:00 2001 From: Pramod S <87521752+pramodcog@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:57:32 +0100 Subject: [PATCH] fix(react-components): settings Menu UI going out of the viewer (#4841) * fixed Settings Menu UI going out of the viewer * added max-height for setting menu and fixed layer menu alignment * bumped react-components to v0.63.1 --- react-components/package.json | 2 +- .../src/components/Architecture/FilterButton.tsx | 15 +++++++++------ .../components/Architecture/SettingsButton.tsx | 14 ++++++++++---- .../RevealToolbar/LayersButton/LayersButton.tsx | 12 ++++++++++-- .../components/RevealToolbar/SettingsButton.tsx | 12 ++++++++++-- react-components/src/components/constants.ts | 2 +- 6 files changed, 41 insertions(+), 16 deletions(-) diff --git a/react-components/package.json b/react-components/package.json index 506ba607140..0dbe39e435d 100644 --- a/react-components/package.json +++ b/react-components/package.json @@ -1,6 +1,6 @@ { "name": "@cognite/reveal-react-components", - "version": "0.64.0", + "version": "0.64.1", "exports": { ".": { "import": "./dist/index.js", diff --git a/react-components/src/components/Architecture/FilterButton.tsx b/react-components/src/components/Architecture/FilterButton.tsx index 1b71cd997f2..177e1d2372c 100644 --- a/react-components/src/components/Architecture/FilterButton.tsx +++ b/react-components/src/components/Architecture/FilterButton.tsx @@ -89,6 +89,7 @@ export const FilterButton = ({ label={label} selectedLabel={selectedLabel} isOpen={isOpen} + setOpen={setOpen} PanelContent={PanelContent} /> ) : ( @@ -133,8 +134,7 @@ const FilterMenu = ({ ( >; PanelContent: ReactElement; }): ReactElement => { return ( - + - - {PanelContent} - + {PanelContent} ); diff --git a/react-components/src/components/Architecture/SettingsButton.tsx b/react-components/src/components/Architecture/SettingsButton.tsx index ea16acfda30..d8e9a4d88ff 100644 --- a/react-components/src/components/Architecture/SettingsButton.tsx +++ b/react-components/src/components/Architecture/SettingsButton.tsx @@ -71,14 +71,14 @@ export const SettingsButton = ({ const flexDirection = getFlexDirection(placement); const children = command.children; return ( - { setOpen(open); }} floatingProps={{ middleware: [offset(TOOLBAR_HORIZONTAL_PANEL_OFFSET)] }} - appendTo={'parent'} - placement="right-start" + container={'parent'} + placement="right-end" style={{ flexDirection, padding: DEFAULT_PADDING @@ -104,7 +104,7 @@ export const SettingsButton = ({ )}> {children.map((child) => createMenuItem(child, t))} - + ); }; @@ -346,3 +346,9 @@ const StyledSlider = styled(Slider)` display: flex; justify-content: space-around; `; + +const StyledMenu = styled(Menu)` + z-index: 998 !important; + max-height: 300px !important; + overflow-y: auto !important; +`; diff --git a/react-components/src/components/RevealToolbar/LayersButton/LayersButton.tsx b/react-components/src/components/RevealToolbar/LayersButton/LayersButton.tsx index 4d6302ad900..57933dbf477 100644 --- a/react-components/src/components/RevealToolbar/LayersButton/LayersButton.tsx +++ b/react-components/src/components/RevealToolbar/LayersButton/LayersButton.tsx @@ -51,7 +51,11 @@ export const LayersButton = ({ return ( <> - + + (false); return ( - ( @@ -54,6 +56,12 @@ export const SettingsButton = ({ highQualitySettings={highQualitySettings} /> {customSettingsContent ?? <>} - + ); }; + +const StyledMenu = styled(Menu)` + z-index: 998 !important; + max-height: 300px !important; + overflow-y: auto !important; +`; diff --git a/react-components/src/components/constants.ts b/react-components/src/components/constants.ts index 3e408be0e6d..634a9179eaa 100644 --- a/react-components/src/components/constants.ts +++ b/react-components/src/components/constants.ts @@ -1,4 +1,4 @@ /*! * Copyright 2024 Cognite AS */ -export const TOOLBAR_HORIZONTAL_PANEL_OFFSET = 6; +export const TOOLBAR_HORIZONTAL_PANEL_OFFSET = 12;