Skip to content

Commit

Permalink
Fix warning and simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
medied committed May 22, 2024
1 parent e2c82b0 commit 7b381d7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/link/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const Sections = ( {
useEffect( () => {
const { title, lang } = activeAttributes;
const [ titlePart, sectionPart ] = title.split( '#' );
const selectedSectionElement = document.querySelector( `.${ sectionsPrefix }-list-item-selected` );

if ( ! sectionPart ) {
setSelectedSection( titlePart );
Expand All @@ -66,15 +67,12 @@ export const Sections = ( {
setLoading( false );
} );
}
}, [] );

useEffect( () => {
const selectedSectionElement = document.querySelector( `.${ sectionsPrefix }-list-item-selected` );
if ( selectedSectionElement ) {
selectedSectionElement.scrollIntoView( { block: 'center' } );
setHoverIndex( selectedSectionElement.tabIndex );
}
}, [ sections ] );
}, [ activeAttributes, sections ] );

useEffect( () => {
const hoveredSectionElement = document.querySelector( `.${ sectionsPrefix }-list-item-hovered` );
Expand Down

0 comments on commit 7b381d7

Please sign in to comment.