@trackunit/react-drawer 2.9.5 → 2.10.1

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/index.cjs.js CHANGED
@@ -526,7 +526,7 @@ const useDrawer = (props) => {
526
526
  // `false` either when it transitions `false -> true` again or once Drawer's
527
527
  // `onExitComplete` signals the panel has genuinely finished exiting
528
528
  // (`handleExitComplete`). See `UseDrawerReturnValue.isExiting`.
529
- const [isExiting, setIsExiting] = react.useState(false);
529
+ const [committedIsExiting, setCommittedIsExiting] = react.useState(false);
530
530
  // Tracks the resolved `isOpen` value as of the last render for which
531
531
  // `isExiting` was derived below, so the render-phase check can detect a
532
532
  // transition without an effect.
@@ -559,10 +559,15 @@ const useDrawer = (props) => {
559
559
  // to `false` and `prevIsOpen` has already caught up to it (from the render
560
560
  // that flipped `isExiting` to `true` in the first place), so `isOpen ===
561
561
  // prevIsOpen` and this block is a no-op on the next render either way.
562
- if (isOpen !== prevIsOpen) {
562
+ const isOpenChanged = isOpen !== prevIsOpen;
563
+ if (isOpenChanged) {
563
564
  setPrevIsOpen(isOpen);
564
- setIsExiting(!isOpen); // true when transitioning to closed, false when transitioning to open
565
+ setCommittedIsExiting(!isOpen); // true when transitioning to closed, false when transitioning to open
565
566
  }
567
+ // React still finishes the render that called `setCommittedIsExiting` above before discarding it, and
568
+ // side effects in that pass (e.g. an Apollo query's `skip` read from `useHold`) are not undone.
569
+ // Returning the new value in that pass too keeps `isExiting` identical in both passes.
570
+ const isExiting = isOpenChanged ? !isOpen : committedIsExiting;
566
571
  const isPendingCloseRef = react.useRef(false);
567
572
  const onCloseRef = react.useRef(onClose);
568
573
  const onOpenRef = react.useRef(onOpen);
@@ -582,7 +587,7 @@ const useDrawer = (props) => {
582
587
  // Fired by `Drawer`'s internal `onExitComplete` prop exactly once per genuine
583
588
  // close→fully-exited cycle — the normal path back to `isExiting: false`.
584
589
  const handleExitComplete = react.useCallback(() => {
585
- setIsExiting(false);
590
+ setCommittedIsExiting(false);
586
591
  }, []);
587
592
  const requestClose = react.useCallback((event, reason) => {
588
593
  if (onBeforeCloseRef.current) {
package/index.esm.js CHANGED
@@ -524,7 +524,7 @@ const useDrawer = (props) => {
524
524
  // `false` either when it transitions `false -> true` again or once Drawer's
525
525
  // `onExitComplete` signals the panel has genuinely finished exiting
526
526
  // (`handleExitComplete`). See `UseDrawerReturnValue.isExiting`.
527
- const [isExiting, setIsExiting] = useState(false);
527
+ const [committedIsExiting, setCommittedIsExiting] = useState(false);
528
528
  // Tracks the resolved `isOpen` value as of the last render for which
529
529
  // `isExiting` was derived below, so the render-phase check can detect a
530
530
  // transition without an effect.
@@ -557,10 +557,15 @@ const useDrawer = (props) => {
557
557
  // to `false` and `prevIsOpen` has already caught up to it (from the render
558
558
  // that flipped `isExiting` to `true` in the first place), so `isOpen ===
559
559
  // prevIsOpen` and this block is a no-op on the next render either way.
560
- if (isOpen !== prevIsOpen) {
560
+ const isOpenChanged = isOpen !== prevIsOpen;
561
+ if (isOpenChanged) {
561
562
  setPrevIsOpen(isOpen);
562
- setIsExiting(!isOpen); // true when transitioning to closed, false when transitioning to open
563
+ setCommittedIsExiting(!isOpen); // true when transitioning to closed, false when transitioning to open
563
564
  }
565
+ // React still finishes the render that called `setCommittedIsExiting` above before discarding it, and
566
+ // side effects in that pass (e.g. an Apollo query's `skip` read from `useHold`) are not undone.
567
+ // Returning the new value in that pass too keeps `isExiting` identical in both passes.
568
+ const isExiting = isOpenChanged ? !isOpen : committedIsExiting;
564
569
  const isPendingCloseRef = useRef(false);
565
570
  const onCloseRef = useRef(onClose);
566
571
  const onOpenRef = useRef(onOpen);
@@ -580,7 +585,7 @@ const useDrawer = (props) => {
580
585
  // Fired by `Drawer`'s internal `onExitComplete` prop exactly once per genuine
581
586
  // close→fully-exited cycle — the normal path back to `isExiting: false`.
582
587
  const handleExitComplete = useCallback(() => {
583
- setIsExiting(false);
588
+ setCommittedIsExiting(false);
584
589
  }, []);
585
590
  const requestClose = useCallback((event, reason) => {
586
591
  if (onBeforeCloseRef.current) {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@trackunit/react-drawer",
3
- "version": "2.9.5",
3
+ "version": "2.10.1",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
7
  "node": ">=24.x"
8
8
  },
9
9
  "dependencies": {
10
- "@trackunit/react-components": "3.5.5",
11
- "@trackunit/css-class-variance-utilities": "2.2.2",
12
- "@trackunit/i18n-library-translation": "2.7.3",
10
+ "@trackunit/react-components": "3.7.0",
11
+ "@trackunit/css-class-variance-utilities": "2.3.0",
12
+ "@trackunit/i18n-library-translation": "2.8.0",
13
13
  "@floating-ui/react": "^0.26.25",
14
14
  "tailwind-merge": "^2.0.0"
15
15
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/drawer/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}