Repository navigation
Fixes #39136: Run drawer onBeforeClose on ESC and backdrop dismissals - #39173
Open
detail-app[bot] wants to merge 2 commits into
Open
detail-app[bot] wants to merge 2 commits into
detail-app[bot] wants to merge 2 commits into
Conversation
detail-app
Bot
force-pushed
the
detail/bug-fix/fixes-39136-run-drawer-onbeforeclose-on-esc-and-ba-ee3f58
branch
from
November 28, 2026 06:05
bb590e4 to
2b07e56
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detail bug report: View on Detail
Describe your changes:
Fixes #39136
The shared
atoms/drawerhook family (useDrawer/useCompositeDrawer/useFormDrawer) is the Save/Cancel drawer pattern used across the UI.onBeforeClose(wired to consumeronCanceland, foruseFormDrawerWithHook, tohookForm.reset()) is the cleanup meant to run on every close.The Escape-key and backdrop-click dismissals close the drawer through
useDrawer's ownhandleOpenChange→closeDrawer, which never invokedonBeforeClose— soonCanceland form-reset silently did not run on those two paths, while the Cancel button and header X did (regression-introduced in the founding commit7b5834eof the atomic-design refactor). User-visible impact: in the Column Bulk Operations grid, pressing ESC closed the edit drawer without runningdiscardPendingEdits, leaving rows in an "edited" state the user believed was discarded;useFormDrawerWithHookconsumers skippedhookForm.reset()on ESC/backdrop, so stale typed values reappeared on the next open.I worked on routing every close reason — programmatic
closeDrawer(), header X, footer Cancel, Escape, and backdrop — through a singleonBeforeClosechoke point, so cleanup runs consistently regardless of how the drawer closes.Type of change:
High-level design:
N/A — small change, but the fix is one focused change to the base hook:
onBeforeClose?: () => voidtoDrawerConfigand invoke it at the top ofuseDrawer.closeDrawer(). Since all close reasons (including react-ariaModalOverlay'sonOpenChange(false)from Escape/backdrop) funnel through that singlecloseDrawer, this is the natural interception point.useCompositeDrawernow forwardsonBeforeClosedown touseDrawerinstead of calling it only on its own wrappers, and its customheader.onClosebranch callsonBeforeCloseexplicitly (it bypassesbaseDrawer.closeDrawer, so it can't rely on the base). The duplicated overriddencloseDrawerwas removed to prevent double-firing.useFormDrawer's wiring (onBeforeClose: onCancel) is unchanged; only the now-stale comments were corrected.The alternative — intercepting
onOpenChangeinuseCompositeDrawer— would have left the bypass inuseDrawerfor any other consumer and required duplicating the interception. Putting it on the base hook fixes the root cause and keeps the composite/form hooks free of close-path bookkeeping.Tests:
Use cases covered
onCancel(previously skipped).onCancel(previously skipped).useFormDrawerWithHookrunshookForm.reset()on ESC and Cancel, so stale typed values don't survive a close+reopen (previously skipped on ESC/backdrop).closeOnEscape: falseopt-out still suppresses Escape (no regression for the consumers relying on it).header.onCloseconsumer still runsonBeforeCloseexactly once andcloseOnBackdrop: falserendering wiring is unchanged (no regression).closeDrawer()runonBeforeCloseexactly once — no zero, no double-fire.Unit tests
useDrawer.test.tsx(new) —onBeforeCloseon programmatic close, Escape, open-doesn't-fire, omitted-handler,closeOnEscape:false.useDrawerBackdrop.test.tsx(new) —onBeforeCloseon backdroponOpenChange(false)(drives the stubbedSlideoutMenuthe repo's jsdom setup requires, since react-aria's interact-outside can't be fired by synthetic events).useCompositeDrawer.test.tsx(new) —onBeforeCloseon header X, Escape, programmatic, and the customheader.onCloseno-double-fire branch.useFormDrawer.test.tsx(updated) —onCancelon header X / Cancel / Escape, open-doesn't-fire, andhookForm.reset()+onCancelon Escape / Cancel for the react-hook-form variant.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
playwright/e2e/Features/ColumnBulkOperations.spec.tsalready exercises Escape and Cancel closes of the edit drawer; this PR does not modify it. Local Playwright verification against a running stack was attempted but blocked (see Manual testing).Manual testing performed
atoms/drawerJest suite (7 suites, 34 tests) — all pass. Reverted the one-line fix inuseDrawer.closeDrawerto confirm the new tests fail in exactly the 12 close-path assertions (RED), then restored.ColumnGrid.test.tsx,useGlossaryCreateDrawer.test.tsx,GlossaryTermDrawer.test.tsx) — 15 pass; no regression. Ran mocked-hook consumer tests (BundleSuiteFormDrawer,DomainDetails,ContextRuleEditor) — 41 pass; return-shape contract preserved.react-hooks/exhaustive-depswarnings, unchanged from pre-fix); Prettier + organize-imports idempotent and conformant;yarn tsc:checkshows 0 errors in the changed files (the fix actually removes 6 baseline TS errors by adding the missingonBeforeClosefield). License headers verified viayarn license-header-fix.http://localhost:8585and no OpenMetadata stack is running. I installed the Playwright Chromium browser and its OS dependencies to unblock it, but reachedconnect ECONNREFUSED 127.0.0.1:8585; the2.0.0-SNAPSHOTDocker images for this dev branch aren't published (manifest unknown), a local build is multi-hour, and the host has ~2.8 GB free RAM (the MySQL+Elasticsearch+OM stack needs ≥5–6 GB). The ESC/backdrop/header-X/Cancel close-path behavior those E2Es would verify is fully covered at the hook level by the unit tests (the same react-ariaonOpenChange(false)→useDrawer.closeDrawercode path), and the specific ColumnGrid consumer regression is covered byColumnGrid.test.tsx.UI screen recording:
Not applicable — this is a bug fix to shared drawer hooks, not a UI feature/feature task. The behaviour change (cleanup now running on ESC/backdrop) has no visible UI surface beyond the drawer closing the same way it did before.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.docs/decisions/(see itsREADME.md). — N/A (restores the original intended contract ofonBeforeClose; no new durable decision).Automatic Fixes PRs can be configured here.