0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 01:22:07 +01:00

Reveal section on minimap click

This commit is contained in:
Thibaud Colas 2023-04-18 01:40:36 +01:00
parent 1c27af0618
commit 6a8096bdb8
2 changed files with 6 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import React, {
import { debounce } from '../../utils/debounce';
import { gettext } from '../../utils/gettext';
import { toggleCollapsiblePanel } from '../../includes/panels';
import Icon from '../Icon/Icon';
import CollapseAll from './CollapseAll';
@ -127,11 +128,13 @@ const Minimap: React.FunctionComponent<MinimapProps> = ({
const listRef = useRef<HTMLOListElement>(null);
const onClickToggle = () => toggleMinimap(!expanded);
const onClickLink = (e: React.MouseEvent) => {
const onClickLink = (link: MinimapMenuItem, e: React.MouseEvent) => {
// Prevent navigating if the link is only partially shown.
if (!expanded) {
e.preventDefault();
}
toggleCollapsiblePanel(link.toggle, true);
toggleMinimap(true);
};

View File

@ -19,7 +19,7 @@ interface MinimapItemProps {
item: MinimapMenuItem;
intersects: boolean;
expanded: boolean;
onClick: (e: React.MouseEvent) => void;
onClick: (item: MinimapMenuItem, e: React.MouseEvent) => void;
}
const requiredMark = <span className="w-required-mark">*</span>;
@ -47,7 +47,7 @@ const MinimapItem: React.FunctionComponent<MinimapItemProps> = ({
className={`w-minimap-item w-minimap-item--${level} ${
intersects ? 'w-minimap-item--active' : ''
} ${hasError ? 'w-minimap-item--error' : ''}`}
onClick={onClick}
onClick={onClick.bind(null, item)}
aria-current={intersects}
// Prevent interacting with the links when they are only partially shown.
tabIndex={expanded ? undefined : -1}