@cloud-ru/ds-accordion 1.1.2-preview-65417497.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.1.2 (2026-09-29)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **FF-9088:** let accordion body shrink to accordion width ([a47a7c2](https://github.com/cloud-ru-tech/snack-v2/commit/a47a7c28554c1e843062985fdd60e71c39f1a2c5))
11
+ - **FF-9192:** slightly optimize first render ([3f30bf8](https://github.com/cloud-ru-tech/snack-v2/commit/3f30bf8975dad8a828f62ad285539e75ae7d93a8))
12
+
6
13
  ## 1.1.1 (2026-09-28)
7
14
 
8
15
  **Note:** Version bump only for package @ds/accordion
@@ -9,12 +9,21 @@ function useCollapseState({ id, keepMounted = false }) {
9
9
  // Контент доживает до конца закрывающей анимации, но при открытии появляется синхронно с
10
10
  // `isOpen` — если монтировать его эффектом, первый кадр раскрытия считается по пустому телу
11
11
  // и высота стартует рывком.
12
- const [keepMountedWhileClosing, setKeepMountedWhileClosing] = (0, react_1.useState)(false);
12
+ // Стартует с `isOpen`: у раскрытого при маунте блока контент уже смонтирован, и эффект не должен
13
+ // добавлять лишний рендер, переключая флаг.
14
+ const [keepMountedWhileClosing, setKeepMountedWhileClosing] = (0, react_1.useState)(isOpen);
13
15
  const isMounted = isOpen || keepMounted || keepMountedWhileClosing;
14
16
  const [isCompletelyOpen, setIsCompletelyOpen] = (0, react_1.useState)(isOpen);
15
17
  const [isCompletelyClose, setIsCompletelyClose] = (0, react_1.useState)(!isOpen);
16
18
  const timeoutRef = (0, react_1.useRef)(null);
19
+ const isFirstRunRef = (0, react_1.useRef)(true);
17
20
  (0, react_1.useEffect)(() => {
21
+ // Начальные флаги уже согласованы с `isOpen`, анимировать нечего: без этого каждый блок при
22
+ // маунте ставил таймер на `ANIMATION_DURATION` ради setState с тем же значением.
23
+ if (isFirstRunRef.current) {
24
+ isFirstRunRef.current = false;
25
+ return;
26
+ }
18
27
  if (isOpen) {
19
28
  setKeepMountedWhileClosing(true);
20
29
  setIsCompletelyClose(false);
@@ -465,6 +465,7 @@
465
465
  overflow:hidden;
466
466
  display:flex;
467
467
  flex-direction:column;
468
+ min-width:0;
468
469
  min-height:0;
469
470
  transition:padding-top var(--sn-collapse-block-animation-duration, 300ms) ease-out, padding-bottom var(--sn-collapse-block-animation-duration, 300ms) ease-out;
470
471
  }
@@ -465,6 +465,7 @@
465
465
  overflow:hidden;
466
466
  display:flex;
467
467
  flex-direction:column;
468
+ min-width:0;
468
469
  min-height:0;
469
470
  transition:padding-top var(--sn-collapse-block-animation-duration, 300ms) ease-out, padding-bottom var(--sn-collapse-block-animation-duration, 300ms) ease-out;
470
471
  }
@@ -6,12 +6,21 @@ export function useCollapseState({ id, keepMounted = false }) {
6
6
  // Контент доживает до конца закрывающей анимации, но при открытии появляется синхронно с
7
7
  // `isOpen` — если монтировать его эффектом, первый кадр раскрытия считается по пустому телу
8
8
  // и высота стартует рывком.
9
- const [keepMountedWhileClosing, setKeepMountedWhileClosing] = useState(false);
9
+ // Стартует с `isOpen`: у раскрытого при маунте блока контент уже смонтирован, и эффект не должен
10
+ // добавлять лишний рендер, переключая флаг.
11
+ const [keepMountedWhileClosing, setKeepMountedWhileClosing] = useState(isOpen);
10
12
  const isMounted = isOpen || keepMounted || keepMountedWhileClosing;
11
13
  const [isCompletelyOpen, setIsCompletelyOpen] = useState(isOpen);
12
14
  const [isCompletelyClose, setIsCompletelyClose] = useState(!isOpen);
13
15
  const timeoutRef = useRef(null);
16
+ const isFirstRunRef = useRef(true);
14
17
  useEffect(() => {
18
+ // Начальные флаги уже согласованы с `isOpen`, анимировать нечего: без этого каждый блок при
19
+ // маунте ставил таймер на `ANIMATION_DURATION` ради setState с тем же значением.
20
+ if (isFirstRunRef.current) {
21
+ isFirstRunRef.current = false;
22
+ return;
23
+ }
15
24
  if (isOpen) {
16
25
  setKeepMountedWhileClosing(true);
17
26
  setIsCompletelyClose(false);
@@ -465,6 +465,7 @@
465
465
  overflow:hidden;
466
466
  display:flex;
467
467
  flex-direction:column;
468
+ min-width:0;
468
469
  min-height:0;
469
470
  transition:padding-top var(--sn-collapse-block-animation-duration, 300ms) ease-out, padding-bottom var(--sn-collapse-block-animation-duration, 300ms) ease-out;
470
471
  }
@@ -465,6 +465,7 @@
465
465
  overflow:hidden;
466
466
  display:flex;
467
467
  flex-direction:column;
468
+ min-width:0;
468
469
  min-height:0;
469
470
  transition:padding-top var(--sn-collapse-block-animation-duration, 300ms) ease-out, padding-bottom var(--sn-collapse-block-animation-duration, 300ms) ease-out;
470
471
  }