From 6e905eabd2f83e5aca9b2a603cb38dd8e2c46f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Reis?= Date: Wed, 30 Oct 2024 17:53:30 +0100 Subject: [PATCH] issue #666: V3: anchor didn't work --- src/components/ArticleV3/Article.js | 5 +++++ src/components/ArticleV3/ArticleScrollTo.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/ArticleV3/Article.js b/src/components/ArticleV3/Article.js index db5ef15c..cc536ebf 100644 --- a/src/components/ArticleV3/Article.js +++ b/src/components/ArticleV3/Article.js @@ -62,6 +62,11 @@ const Article = ({ console.info('[Article] onCellClickHandler', dataHref) setSelectedDataHref(dataHref) } + + if (e.target.hasAttribute('data-idx')) { + e.preventDefault(); + setSelectedCellIdx(e.target.getAttribute('data-idx')); + } } return ( diff --git a/src/components/ArticleV3/ArticleScrollTo.js b/src/components/ArticleV3/ArticleScrollTo.js index 480d4b2b..606a4ee4 100644 --- a/src/components/ArticleV3/ArticleScrollTo.js +++ b/src/components/ArticleV3/ArticleScrollTo.js @@ -19,7 +19,7 @@ const ArticleScrollTo = () => { } } useEffect(() => { - if(selectedCellIdxFromStore !== -1 && selectedCellIdx !== -1 && selectedCellIdxFromStore !== selectedCellIdx) { + if(selectedCellIdxFromStore !== -1 && selectedCellIdxFromStore !== selectedCellIdx) { moveTo(selectedCellIdxFromStore) setQuery({ [DisplayLayerCellIdxQueryParam]: selectedCellIdxFromStore }) }