Skip to content
Snippets Groups Projects
Commit 7218e95f authored by David Bühler's avatar David Bühler
Browse files

[ivette] ASTinfo: scrolls to the hovered marker info.

parent 894086f7
No related branches found
No related tags found
No related merge requests found
...@@ -318,6 +318,10 @@ export default function ASTinfo(): JSX.Element { ...@@ -318,6 +318,10 @@ export default function ASTinfo(): JSX.Element {
States.MetaSelection.on(pinMarker); States.MetaSelection.on(pinMarker);
return () => States.MetaSelection.off(pinMarker); return () => States.MetaSelection.off(pinMarker);
}, [pinMarker]); }, [pinMarker]);
const scrollTarget = React.useRef<HTMLInputElement>(null);
React.useEffect(() => {
scrollTarget.current?.scrollIntoView({ block: 'nearest' });
});
// Rendering // Rendering
const renderMark = (mark: Mark): JSX.Element | null => { const renderMark = (mark: Mark): JSX.Element | null => {
const { marker } = mark; const { marker } = mark;
...@@ -331,7 +335,8 @@ export default function ASTinfo(): JSX.Element { ...@@ -331,7 +335,8 @@ export default function ASTinfo(): JSX.Element {
const onSelect = () => void States.setSelection(mark); const onSelect = () => void States.setSelection(mark);
const onHover = const onHover =
(h: boolean): void => States.setHovered(h ? mark : undefined); (h: boolean): void => States.setHovered(h ? mark : undefined);
return ( const ref = isHovered ? scrollTarget : undefined;
const markInfo =
<MarkInfos <MarkInfos
key={marker} key={marker}
marker={marker} marker={marker}
...@@ -344,8 +349,8 @@ export default function ASTinfo(): JSX.Element { ...@@ -344,8 +349,8 @@ export default function ASTinfo(): JSX.Element {
onRemove={onRemove} onRemove={onRemove}
onHover={onHover} onHover={onHover}
onSelect={onSelect} onSelect={onSelect}
/> />;
); return <div ref={ref}>{markInfo}</div>;
}; };
return ( return (
<> <>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment