Skip to content

fix(Drawer): account for cursor position in resize#12506

Open
kmcfaul wants to merge 1 commit into
patternfly:mainfrom
kmcfaul:drawer-resize-fix
Open

fix(Drawer): account for cursor position in resize#12506
kmcfaul wants to merge 1 commit into
patternfly:mainfrom
kmcfaul:drawer-resize-fix

Conversation

@kmcfaul

@kmcfaul kmcfaul commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What: Closes #12438

This bug appears to be unrelated to the unified changes, it was just easier to see on the pill resizable drawers. The issue stems from the logic making the drag edge align with the panel edge and not the initial cursor position on the splitter. So the initial jump was the drawer's edge re-aligning on the cursor position.

Debugging assisted by Cursor AI

Summary by CodeRabbit

  • Refactor
    • Improved the internal state management for drawer panel resize operations to enhance stability during user interactions.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

DrawerPanelContent resize logic is refactored to use a single persistent resizeState ref (holding initialPointerPos, initialPanelSize, and currWidth) replacing local variables. A new setInitialResizeState helper captures initial panel dimensions on drag start; handleControlMove and all end/keyboard handlers read from and write to this ref.

DrawerPanelContent resize state refactor

Layer / File(s) Summary
resizeState ref declaration and initialization helpers
packages/react-core/src/components/Drawer/DrawerPanelContent.tsx
Declares the resizeState ref with initialPointerPos, initialPanelSize, and currWidth fields; introduces the setInitialResizeState helper that reads getBoundingClientRect() (selecting height for bottom position, width otherwise); updates both the touch-start and mouse-down handlers to call it in place of the previous ad-hoc local-variable initialization.
handleControlMove and resize completion handlers
packages/react-core/src/components/Drawer/DrawerPanelContent.tsx
Refactors handleControlMove to compute delta and newSize from resizeState.current, applies the flex-basis CSS token and disables overflow anchoring for bottom resizing, then writes the result back to resizeState.current.currWidth; updates the mouseup, touchend, and keyboard handlers to pass resizeState.current.currWidth to the onResize callback instead of the now-removed local currWidth variable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: addressing cursor position handling in the Drawer resize functionality.
Linked Issues check ✅ Passed The PR correctly addresses issue #12438 by refactoring resize logic to properly track initial cursor position via resizeState ref, eliminating the drawer jump on resize initiation.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the drawer resize cursor position bug; no unrelated modifications detected in DrawerPanelContent.tsx.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@patternfly-build

patternfly-build commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

@kmcfaul kmcfaul closed this Jun 23, 2026
@kmcfaul kmcfaul reopened this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - Drawer - resizable pill drawer jumps

3 participants