mirror of
https://github.com/Redocly/redoc.git
synced 2025-05-03 07:03:46 +03:00
parent
f944da0e7d
commit
3df72fb99f
|
@ -39,9 +39,9 @@ const isModifiedEvent = (event) =>
|
||||||
export function Link(props: { to: string; className?: string; children?: any }) {
|
export function Link(props: { to: string; className?: string; children?: any }) {
|
||||||
const store = React.useContext(StoreContext);
|
const store = React.useContext(StoreContext);
|
||||||
const clickHandler = React.useCallback(
|
const clickHandler = React.useCallback(
|
||||||
(event) => {
|
(event: React.MouseEvent<HTMLAnchorElement>) => {
|
||||||
if (!store) return;
|
if (!store) return;
|
||||||
navigate(store.menu.history, event);
|
navigate(store.menu.history, event, props.to);
|
||||||
},
|
},
|
||||||
[store],
|
[store],
|
||||||
);
|
);
|
||||||
|
@ -60,14 +60,14 @@ export function Link(props: { to: string; className?: string; children?: any })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigate(history: HistoryService, event) {
|
function navigate(history: HistoryService, event: React.MouseEvent<HTMLAnchorElement>, to: string) {
|
||||||
if (
|
if (
|
||||||
!event.defaultPrevented && // onClick prevented default
|
!event.defaultPrevented && // onClick prevented default
|
||||||
event.button === 0 && // ignore everything but left clicks
|
event.button === 0 && // ignore everything but left clicks
|
||||||
!isModifiedEvent(event) // ignore clicks with modifier keys
|
!isModifiedEvent(event) // ignore clicks with modifier keys
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
history.replace(this.props.to);
|
history.replace(to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user