Skip to content

Commit bc83e30

Browse files
committed
dont reload the page on collapsible home link
1 parent a77ca6d commit bc83e30

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/public/chrome/ui/header/collapsible_nav.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function mockProps() {
6363
storage: new StubBrowserStorage(),
6464
onIsOpenUpdate: () => {},
6565
onIsLockedUpdate: () => {},
66+
navigateToApp: () => {},
6667
};
6768
}
6869

src/core/public/chrome/ui/header/collapsible_nav.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ interface Props {
7878
storage?: Storage;
7979
onIsLockedUpdate: OnIsLockedUpdate;
8080
onIsOpenUpdate: (isOpen?: boolean) => void;
81+
navigateToApp: (appId: string) => void;
8182
}
8283

8384
export function CollapsibleNav({
@@ -89,6 +90,7 @@ export function CollapsibleNav({
8990
onIsOpenUpdate,
9091
homeHref,
9192
id,
93+
navigateToApp,
9294
storage = window.localStorage,
9395
}: Props) {
9496
const lockRef = useRef<HTMLButtonElement>(null);
@@ -124,7 +126,19 @@ export function CollapsibleNav({
124126
label: 'Home',
125127
iconType: 'home',
126128
href: homeHref,
127-
onClick: () => onIsOpenUpdate(false),
129+
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
130+
onIsOpenUpdate(false);
131+
if (
132+
event.isDefaultPrevented() ||
133+
event.altKey ||
134+
event.metaKey ||
135+
event.ctrlKey
136+
) {
137+
return;
138+
}
139+
event.preventDefault();
140+
navigateToApp('home');
141+
},
128142
},
129143
]}
130144
maxWidth="none"

src/core/public/chrome/ui/header/header.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ export class Header extends Component<HeaderProps, State> {
288288
this.toggleCollapsibleNavRef.current.focus();
289289
}
290290
}}
291+
navigateToApp={this.props.application.navigateToApp}
291292
/>
292293
) : (
293294
// TODO #64541

0 commit comments

Comments
 (0)