Skip to content

Commit

Permalink
Bug fix: jumping view carousel icon and non-centered selection popup (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms authored Aug 9, 2022
1 parent a78b0d6 commit 3dda6e0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
padding-top: 8px;
}

.WebvizViewList__Below {
margin-left: -151px;
}

.WebvizViewList__Aside {
margin-top: -20px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ export const ViewList: React.FC<ViewListProps> = (props: ViewListProps) => {
views: View[];
}[]
>([]);
const ref = React.useRef<HTMLDivElement>(null);

React.useLayoutEffect(() => {
if (props.anchorElement) {
const rect = props.anchorElement.getBoundingClientRect();
if (props.location === "below") {
setMainPosition({
x: rect.left + rect.width / 2,
x:
rect.left +
rect.width / 2 -
(ref.current?.getBoundingClientRect().width || 0) / 2,
y: rect.bottom + 20,
});
} else {
Expand All @@ -46,7 +50,7 @@ export const ViewList: React.FC<ViewListProps> = (props: ViewListProps) => {
});
}
}
}, [props.anchorElement]);
}, [props.anchorElement, props.location, ref.current]);

React.useEffect(() => {
const viewList: {
Expand Down Expand Up @@ -84,6 +88,7 @@ export const ViewList: React.FC<ViewListProps> = (props: ViewListProps) => {
top: mainPosition.y,
display: props.open ? "block" : "none",
}}
ref={ref}
>
<div
className={`WebvizViewList__Arrow WebvizViewList__Arrow${
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.WebvizViewSelector {
display: flex;
align-items: center;
justify-items: center;
border-radius: 4px;
cursor: pointer;
justify-content: space-evenly;
padding-left: 20px;
padding-right: 16px;
overflow: hidden;
Expand Down Expand Up @@ -34,3 +34,8 @@
overflow: hidden;
padding-left: 12px;
}

.WebvizViewSelector__Icon {
display: flex;
justify-content: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export const ViewSelector: React.FC<ViewSelectorProps> = (
props.open,
store.state.activePluginId,
store.state.pluginsData,
viewNameRef.current,
viewCarouselRef.current,
]);

React.useEffect(() => {
Expand Down Expand Up @@ -141,7 +143,7 @@ export const ViewSelector: React.FC<ViewSelectorProps> = (
}}
onClick={() => setMenuOpen(true)}
>
<div ref={viewCarouselRef}>
<div ref={viewCarouselRef} className="WebvizViewSelector__Icon">
<Icon name="view_carousel" />
</div>
<div
Expand Down

0 comments on commit 3dda6e0

Please sign in to comment.