Skip to content

Commit

Permalink
added container height to resolve extra scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishal2002 committed May 1, 2024
1 parent 020e4ce commit 9e82491
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/tools/ToolsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRef, useEffect } from 'react';
import Paragraph from '../typography/Paragraph'
export default function toolsList({ toolsData }) {
const categoryRefs = useRef({});
const containerRef = useRef(null);

// Below UseEffect scrolls the page to a specific category referenced in the URL hash.
useEffect(() => {
Expand All @@ -12,13 +13,13 @@ export default function toolsList({ toolsData }) {
const decodedHash = decodeURIComponent(hash.slice(1));
const categoryRef = categoryRefs.current[decodedHash];
if (categoryRef) {
categoryRef.scrollIntoView({ behavior: 'smooth', block: 'start' });
categoryRef.scrollIntoView({ behavior: 'smooth', block: 'start', inline:'nearest' });
}
}
},[]);

return (
<div className="" data-testid="ToolsList-main" >
<div ref={containerRef} data-testid="ToolsList-main" className="max-h-screen overflow-y-auto" >
{Object.keys(toolsData).map((categoryName, index) => {
if(toolsData[categoryName].toolsList.length > 0) return (
<div className='my-8' key={index} id={categoryName} ref={el => categoryRefs.current[categoryName] = el}>
Expand Down

0 comments on commit 9e82491

Please sign in to comment.