Note detail overlay (z-[9999]) blocks reference modals & dnd-kit crash
Describe the bug
When opening a note in the full-screen detail view, clicking the Reference button does not show the reference modal.
The modal DOM elements are mounted and API requests succeed, but the modal is completely invisible because it is rendered underneath the detail view due to a stacking context / z-index conflict. Additionally, a TypeError: Cannot use 'in' operator to search for 'x' in undefined crash occasionally occurs in dnd-kit during modal mounting.
To Reproduce
- Open any long note to enter the full-screen detail view.
- Click on the Reference note.
- Observe that no dialog/modal appears on the screen (it is trapped behind the detail page backdrop).
- (Optional) Check the DevTools console; in some states, a
dnd-kitcoordinate calculation error (Cannot use 'in' operator to search for 'x' in undefined) is thrown. - If you trigger a window resize or adjust styles via console, the modal is found rendered behind the detail overlay.
Expected behavior
The reference note should pop up on the topmost layer above the note detail page, allowing users to select.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Macos Sonoma 14.7.6
- Browser Edge
- Version 152.0.4191.62
Additional context
We investigated the root causes and verified the fix locally:
Root Cause Analysis (z-index mismatch):
- The note detail overlay uses the Tailwind class:
fixed inset-0 z-[9999] bg-background overflow-hidden(computedz-index: 9999). - The HeroUI modal portal wrapper is attached to
<body>with:flex w-screen fixed inset-0 z-50 overflow-x-auto justify-center(computedz-index: 50). - Even though the inner
<section>of the modal hasz-index: 2000, because its parent wrapper only hasz-index: 50, the entire modal stacking context is placed behind the detail page overlay (z-index: 9999).
- The note detail overlay uses the Tailwind class:
dnd-kit crash:
- In
dnd-kit's coordinate delta helper function (ft(e, t)in the bundle), passing an undefined coordinate during initial mount throwsCannot use 'in' operator to search for 'x' in undefined. A defensive null checkif (!e || !t) return false;resolves this.
- In
Suggested Fix:
- Change the detail view overlay from
z-[9999]toz-40or standard backdrop elevation so it stays below modals (z-50). - Alternatively, elevate the modal wrapper/portal container
z-indexto higher than9999(e.g.z-[10000]). - Add null checks for drag-and-drop coordinate handlers.
- Change the detail view overlay from
Source: blinkospace/blinko