From 9162b7165ad446cf12cea88eecf94f2787de6e75 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 13 Apr 2019 16:49:10 +0100 Subject: [PATCH] Prefer to keep the start anchor visible --- src/devtools/views/Components/Element.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/devtools/views/Components/Element.js b/src/devtools/views/Components/Element.js index bf81291f4a..48efeba641 100644 --- a/src/devtools/views/Components/Element.js +++ b/src/devtools/views/Components/Element.js @@ -80,15 +80,17 @@ export default function ElementView({ data, index, style }: Props) { // However, even calling scrollIntoView() on their parent node // wouldn't guarantee that it will be *fully* brought into view. // As a workaround, we'll have two anchor spans, and scroll each into view. - if (scrollAnchorStartRef.current !== null) { - scrollAnchorStartRef.current.scrollIntoView({ + if (scrollAnchorEndRef.current !== null) { + scrollAnchorEndRef.current.scrollIntoView({ behavior: 'auto', block: 'nearest', inline: 'nearest', }); } - if (scrollAnchorEndRef.current !== null) { - scrollAnchorEndRef.current.scrollIntoView({ + if (scrollAnchorStartRef.current !== null) { + // We scroll the start anchor last because it's + // more important for it to be in the view. + scrollAnchorStartRef.current.scrollIntoView({ behavior: 'auto', block: 'nearest', inline: 'nearest',