Skip to content

Commit

Permalink
fix(comparison-table): Fix comparison table not growing
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomateus committed Jan 18, 2024
1 parent 208aac5 commit dc394ce
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lib/components/comparisonTable/hooks/useComparisonTable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import debounce from 'lodash.debounce';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';

import { ArrowValues } from '../components/TableArrows';
import generateId from '../../../util/generateId';
Expand Down Expand Up @@ -51,6 +51,18 @@ export const useComparisonTable = () => {
};
}, []);

useLayoutEffect(() => {
const resetHeaderWidth = () => {
if (headerRef.current) {
setHeaderWidth(headerRef.current.clientWidth);
}
}

window.addEventListener('resize', resetHeaderWidth);

return () => window.removeEventListener('resize', resetHeaderWidth);
}, []);

const handleTableScroll = () => {
if (!headerRef.current) {
return;
Expand Down

0 comments on commit dc394ce

Please sign in to comment.