Skip to content

Commit e9f90dc

Browse files
authored
HELP-8072 & HELP-8071 action menu tooltip fixes (#336)
1 parent 370ed93 commit e9f90dc

File tree

8 files changed

+12522
-19524
lines changed

8 files changed

+12522
-19524
lines changed

lib/components/ActionsMenu/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,7 @@ export const ActionsMenuBody = ({
335335
);
336336

337337
if (customTriggerComponent) {
338-
triggerComponent = React.cloneElement(customTriggerComponent, {
339-
...triggerProps,
340-
...(customTriggerComponent?.props || {})
341-
});
338+
triggerComponent = <div {...triggerProps}>{customTriggerComponent}</div>;
342339
}
343340

344341
const value = useMemo(

lib/components/Popover/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const StyledPopover = styled.div`
8787
height: 0;
8888
width: 0;
8989
padding: 0;
90+
overflow: hidden;
9091
}
9192
9293
&.visible {
@@ -350,8 +351,12 @@ export default function Popover({
350351
);
351352

352353
const floatingProps = useMemo(
353-
() => getFloatingProps(props),
354-
[getFloatingProps, props]
354+
() =>
355+
getFloatingProps({
356+
...props,
357+
className: `${props.className} ${visiblePopoverClassName}`
358+
}),
359+
[getFloatingProps, props, visiblePopoverClassName]
355360
);
356361

357362
return (

lib/components/SideNav/SideNav.stories.js

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import {
55
BrowserRouter as Router,
66
Route,
77
Link,
8-
useLocation,
9-
matchPath,
10-
Switch,
11-
Redirect,
12-
useParams
8+
Routes,
9+
useParams,
10+
useMatch,
11+
Navigate
1312
} from "react-router-dom";
1413
import { H5, P } from "../Typography";
1514
import Box from "../Box";
@@ -63,46 +62,48 @@ const PageCard = ({ children }) => {
6362
};
6463

6564
const SideBarWithConfig = () => {
66-
const location = useLocation();
65+
const isHome = useMatch("/");
66+
const isProfile = useMatch("/profile");
67+
const isSearch = useMatch("/search");
6768

6869
const items = [
6970
{
7071
iconName: "building",
7172
name: "Home",
7273
component: makeLinkComponent("/"),
7374
actionType: "link",
74-
isActive: matchPath(location.pathname, { path: "/", exact: true })
75+
isActive: !!isHome
7576
},
7677
{
7778
iconName: "user",
7879
name: "My profile",
7980
component: makeLinkComponent("/profile"),
8081
actionType: "link",
81-
isActive: matchPath(location.pathname, { path: "/profile" })
82+
isActive: !!isProfile
8283
},
8384
{
8485
iconName: "id-card",
8586
name: "Search Page",
8687
component: makeLinkComponent("/search"),
8788
actionType: "link",
88-
isActive: matchPath(location.pathname, { path: "/search" })
89+
isActive: isSearch
8990
},
9091
{
9192
iconName: "snowflake",
9293
name: "Filter",
93-
hide: !matchPath(location.pathname, { path: "/search" }), // Specify hide if you want to hide this item
94+
hide: !isSearch, // Specify hide if you want to hide this item
9495
component: makePanelComponent("Filter"),
9596
actionType: "component", // Use 'component' for a component
96-
pageSpecific: matchPath(location.pathname, { path: "/search" }),
97+
pageSpecific: isSearch,
9798
isExpandedByDefault: true
9899
},
99100
{
100101
iconName: "sun",
101102
name: "People",
102-
hide: !matchPath(location.pathname, { path: "/profile" }), // Specify hide if you want to hide this item
103+
hide: !isProfile, // Specify hide if you want to hide this item
103104
component: makePanelComponent("People"),
104105
actionType: "component", // Use 'component' for a component
105-
pageSpecific: matchPath(location.pathname, { path: "/profile" }),
106+
pageSpecific: isProfile,
106107
isExpandedByDefault: true
107108
},
108109
{
@@ -165,24 +166,34 @@ const SideBarWithConfig = () => {
165166
return (
166167
<Flex>
167168
<SideNav items={items} sideNavHeight="500px" />
168-
<Switch>
169-
<Route exact path="/">
170-
<PageCard>
171-
<div>Home</div>
172-
</PageCard>
173-
</Route>
174-
<Route path="/profile">
175-
<PageCard>
176-
<div>Profile route</div>
177-
</PageCard>
178-
</Route>
179-
<Route path="/teams/:teamId">
180-
<PageCard>
181-
<Teams />
182-
</PageCard>
183-
</Route>
184-
<Redirect from="/iframe.html" to="/" />
185-
</Switch>
169+
<Routes>
170+
<Route
171+
path="/"
172+
element={
173+
<PageCard>
174+
<div>Home</div>
175+
</PageCard>
176+
}
177+
/>
178+
<Route
179+
path="/profile"
180+
element={
181+
<PageCard>
182+
<div>Profile route</div>
183+
</PageCard>
184+
}
185+
/>
186+
<Route
187+
path="/teams/:teamId"
188+
element={
189+
<PageCard>
190+
<Teams />
191+
</PageCard>
192+
}
193+
/>
194+
195+
<Route path="/iframe.html" element={<Navigate to="/" replace />} />
196+
</Routes>
186197
</Flex>
187198
);
188199
};

lib/components/SideNav/index.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,29 +63,11 @@ const SideNavItems = styled("div")((props) =>
6363
})
6464
);
6565

66-
const PanelControlTooltip = styled(Popover)((props) =>
67-
css({
68-
alignSelf: "center",
69-
position: props.hideExpandedControl ? "absolute" : "relative",
70-
right: props.hideExpandedControl ? "r" : "initial",
71-
top: "r",
72-
display: props.hideExpandedControl ? "block" : "none !important",
73-
borderTop: props.hideExpandedControl ? "none" : "solid 1px",
74-
borderTopColor: themeGet("colors.greyLighter")(props),
75-
paddingTop: props.hideExpandedControl ? "0" : "r",
76-
width: props.hideExpandedControl ? "auto" : "100%",
77-
justifyContent: "center",
78-
"&:focus": {
79-
outline: "0"
80-
},
81-
[`@media screen and (max-width: ${SMALL_SCREEN_BREAKPOINT}px)`]: {
82-
border: "none"
83-
},
84-
"& .popoverText": {
85-
marginTop: props.hideExpandedControl ? "0" : "s"
86-
}
87-
})
88-
);
66+
const PanelControlTooltip = styled(Popover)`
67+
position: absolute;
68+
right: ${themeGet("space.r")};
69+
top: ${themeGet("space.r")};
70+
`;
8971

9072
const PanelControl = styled("button")((props) =>
9173
css({
@@ -248,7 +230,11 @@ const SideNav = ({ items, sideNavHeight }) => {
248230
/>
249231
);
250232

251-
if (item.pageSpecific && !orderedItems[index - 1].pageSpecific) {
233+
if (
234+
item.pageSpecific &&
235+
!orderedItems[index - 1].pageSpecific &&
236+
!isSmallScreen
237+
) {
252238
return (
253239
<>
254240
<Divider
@@ -286,7 +272,6 @@ const SideNav = ({ items, sideNavHeight }) => {
286272
<PanelControlTooltip
287273
width="80px"
288274
textAlign="center"
289-
hideExpandedControl
290275
direction="left"
291276
text="Hide panel"
292277
>

lib/components/StyledLink/StyledLink.stories.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import StyledLink from ".";
33
import Box from "../Box";
44
import Flex from "../Flex";
55
import Spacer from "../Spacer";
6-
import { BrowserRouter, Route, Switch } from "react-router-dom";
6+
import { BrowserRouter, Route, Routes } from "react-router-dom";
77

88
export default {
99
title: "Components/StyledLink",
@@ -64,13 +64,19 @@ export const reactLink = () => (
6464
{route.label}
6565
</StyledLink>
6666
))}
67-
<Switch>
67+
<Routes>
6868
{routes.map((route) => (
69-
<Route key={route.path} path={route.path} exact={route.exact}>
70-
<div style={{ padding: "100px" }}>ROUTE RENDERED: {route.label}</div>
71-
</Route>
69+
<Route
70+
key={route.path}
71+
path={route.path}
72+
element={
73+
<div style={{ padding: "100px" }}>
74+
ROUTE RENDERED: {route.label}
75+
</div>
76+
}
77+
/>
7278
))}
73-
</Switch>
79+
</Routes>
7480
</BrowserRouter>
7581
);
7682
reactLink.storyName = "Using react-router-dom";
Binary file not shown.

0 commit comments

Comments
 (0)