Skip to content

Commit

Permalink
Bug fix: Overlay hiding menu, conflicting z-index properties (#220)
Browse files Browse the repository at this point in the history
* Bug fix: `Overlay` hiding menu, conflicting `z-index` properties
Added `zIndex` prop to `Overlay`
  • Loading branch information
rubenthoms committed Jun 27, 2022
1 parent 221181b commit 66896e9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED] - YYYY-MM-DD

### Fixed

- [#220](https://github.com/equinor/webviz-core-components/pull/220) - `Overlay` was hiding menu due to conflicting z-index properties. Added `zIndex` prop to `Overlay` component and adjusted consumers.

### Added

- [#207](https://github.com/equinor/webviz-core-components/pull/207) - Added `storybook` and stories for each component. Added publishment of `storybook` to GitHub workflow. Added `storybook` link to README.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
position: fixed;
height: 100vh;
width: fit-content;
z-index: 1001;
z-index: 1002;
display: inline-block;
}

Expand Down
1 change: 0 additions & 1 deletion react/src/lib/components/Overlay/Overlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
left: 0;
top: 0;
background-color: black;
z-index: 1010;
}
6 changes: 6 additions & 0 deletions react/src/lib/components/Overlay/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./Overlay.css";

export type OverlayProps = {
visible: boolean;
zIndex?: number;
onClick: () => void;
};

Expand Down Expand Up @@ -54,6 +55,7 @@ export const Overlay: React.FC<OverlayProps> = (props) => {
style={{
display: opacity > 0 ? "block" : "none",
opacity: opacity,
zIndex: props.zIndex || 1001,
}}
onClick={props.onClick}
></div>
Expand All @@ -65,6 +67,10 @@ Overlay.propTypes = {
* Set if the overlay shall be shown or not.
*/
visible: PropTypes.bool.isRequired,
/**
* Optionally defined a preferred z-index for the overlay.
*/
zIndex: PropTypes.number,
/**
* Callback function called when the overlay is clicked on.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const ViewSelector: React.FC<ViewSelectorProps> = (
<Overlay
visible={menuOpen}
onClick={() => setMenuOpen(false)}
zIndex={1003}
/>
<ViewList
open={menuOpen}
Expand Down

0 comments on commit 66896e9

Please sign in to comment.