Skip to content

fix(ui): useDocumentDrawer always reports the drawer as closed - #19235

Open
digitalwerber wants to merge 1 commit into
payloadcms:mainfrom
digitalwerber:fix/document-drawer-is-open
Open

digitalwerber wants to merge 1 commit into
payloadcms:mainfrom
digitalwerber:fix/document-drawer-is-open

Conversation

@digitalwerber

Copy link
Copy Markdown

What?

useDocumentDrawer now derives isDrawerOpen from the modal state of its own drawer slug instead of returning a hardcoded false.

Why?

Consumers rely on it. The relationship table resets its current document id when the drawer closes, and the relationship field disables its select while the drawer is open. With false hardcoded, the edit drawer of a join field row never opened a second time.

How?

The hook already subscribes to the modal context, so this adds no subscription; the memoized drawer state only changes when this drawer opens or closes. Adds an e2e test in test/joins that opens, closes and reopens a row's drawer.

Fixes #19232

`useDocumentDrawer` returned a hardcoded `isDrawerOpen: false` to avoid
re-renders. Consumers rely on it: the relationship table resets the
current document id once its drawer closes, and the relationship field
disables its select while the drawer is open. Because the id was never
reset, the edit drawer of a join field row did not open again after it
was closed.

Derive `isDrawerOpen` from the modal state of the drawer's own slug. The
hook already subscribes to the modal context, so this adds no
subscription, and the memoized state only changes when this drawer
opens or closes.
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 39a9df9 and c5b71af.

Files selected for processing: 2
  • packages/ui/src/elements/DocumentDrawer/index.tsx
  • test/joins/e2e.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The drawer context now reports whether its modal is open. An end-to-end test checks that a joined document’s drawer can be closed and reopened from the same row.

Changes: Join drawer state

Layer / File(s) Summary
Track drawer state and verify reopening
packages/ui/src/elements/DocumentDrawer/index.tsx, test/joins/e2e.spec.ts
useDocumentDrawer reads the open state for its drawer slug and includes that state in its memoized context. The end-to-end test verifies that the drawer and title input are visible after reopening.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: jarrodmflesch, jessrynkar

Merge Risk: Minimal · up to c5b71

The PR addresses the reported drawer reopening issue and adds coverage for the affected workflow.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the main fix: correcting useDocumentDrawer so it reports the drawer’s open state.
Description check Passed The description directly explains the bug, its impact, the implementation, and the added end-to-end test.
Linked Issues check Passed Issue #19232 requires useDocumentDrawer to report the open state for its own drawer. packages/ui/src/elements/DocumentDrawer/index.tsx derives isDrawerOpen from modalState[drawerSlug]?.isOpen …
Out of Scope Changes check Passed The reviewed changes are limited to the drawer-state fix in useDocumentDrawer and an E2E regression test in test/joins. Both changes directly support issue #19232.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #19232 requires useDocumentDrawer to report the open state for its own drawer. packages/ui/src/elements/DocumentDrawer/index.tsx derives isDrawerOpen from modalState[drawerSlug]?.isOpen and includes it in the memoized state dependencies. The added join E2E coverage verifies that a row drawer closes and reopens.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

This branch has not been deployed

No deployments
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.

Join field: edit drawer of a row does not open again after closing it (useDocumentDrawer always reports isDrawerOpen: false)

1 participant