@popsure/dirty-swan 0.37.1 → 0.37.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popsure/dirty-swan",
3
- "version": "0.37.1",
3
+ "version": "0.37.2",
4
4
  "author": "Vincent Audoire <vincent@getpopsure.com>",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -2,13 +2,13 @@ import debounce from 'lodash.debounce';
2
2
  import { useCallback, useEffect, useRef, useState } from 'react';
3
3
 
4
4
  import { ArrowValues } from '../components/TableArrows';
5
+ import generateId from '../../../util/generateId';
5
6
 
6
7
  export const useComparisonTable = () => {
7
8
  const [showMore, setShowMore] = useState<boolean>(false);
8
9
  const [headerWidth, setHeaderWidth] = useState(1400);
9
-
10
+ const [headerId, setHeaderId] = useState('');
10
11
  const [selectedTabIndex, setSelectedTabIndex] = useState(0);
11
-
12
12
  const [selectedSection, setSelectedSection] = useState('');
13
13
 
14
14
  const headerRef = useRef<HTMLDivElement | null>(null);
@@ -110,8 +110,25 @@ export const useComparisonTable = () => {
110
110
  setShowMore(!showMore);
111
111
  };
112
112
 
113
+ useEffect(() => {
114
+ if (headerRef.current) {
115
+ return;
116
+ }
117
+
118
+ const headerById = document.getElementById(headerId);
119
+
120
+ if (headerById) {
121
+ scrollContainerCallbackRef(headerById);
122
+ }
123
+ }, [headerId, scrollContainerCallbackRef]);
124
+
125
+ useEffect(() => {
126
+ setHeaderId(generateId());
127
+ }, []);
128
+
113
129
  return {
114
130
  headerWidth,
131
+ headerId,
115
132
  contentContainerRef,
116
133
  selectedSection,
117
134
  setSelectedSection,
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import { Fragment } from 'react';
2
+ import { Fragment, useEffect } from 'react';
3
3
  import { ScrollSync, ScrollSyncPane } from 'react-scroll-sync';
4
4
 
5
5
  import { AccordionItem } from './components/AccordionItem';
@@ -85,6 +85,7 @@ const ComparisonTable = <T extends { id: number }>(
85
85
  handleArrowsClick,
86
86
  toggleMoreRows,
87
87
  showMore,
88
+ headerId,
88
89
  } = useComparisonTable();
89
90
 
90
91
  const cssVariablesStyle = {
@@ -105,6 +106,7 @@ const ComparisonTable = <T extends { id: number }>(
105
106
  <div className={classNames(baseStyles.header, styles?.header)}>
106
107
  <ScrollSyncPane>
107
108
  <div
109
+ id={headerId}
108
110
  className={classNames(baseStyles.container, {
109
111
  [baseStyles.noScrollBars]: hideScrollBars,
110
112
  })}