Skip to content

Commit 3fdf51c

Browse files
authored
[dev-overlay] HOTFIX: clicking nav escapes the overlay (#75876)
Following up of #75679 ### Why? Clicking the navigation escapes the overlay. It is because the navigation component is outside of the dialog component. #### Before https://github.com/user-attachments/assets/e7c63261-c44b-4af7-936d-1750dff07527 #### After https://github.com/user-attachments/assets/979421fa-fb71-481d-bd58-6703298db28b ### How? Since we already have logic to prevent closing overlay when clicked outside the component for dev indicator, add the header to this CSS selectors list as well.
1 parent 2e47628 commit 3fdf51c

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/dialog/dialog.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE = [
1616
'[data-next-mark]',
1717
'[data-issues-open]',
1818
'#nextjs-dev-tools-menu',
19+
'[data-nextjs-error-overlay-nav]',
1920
]
2021

2122
const Dialog: React.FC<DialogProps> = function Dialog({

packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/errors/dialog/dialog.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ export const DIALOG_STYLES = css`
4141
border-color: var(--color-gray-400);
4242
}
4343
44-
&:has(~ .error-overlay-nav .error-overlay-notch[data-side='left']) {
44+
&:has(
45+
~ [data-nextjs-error-overlay-nav] .error-overlay-notch[data-side='left']
46+
) {
4547
border-top-left-radius: 0;
4648
}
4749
48-
&:has(~ .error-overlay-nav .error-overlay-notch[data-side='right']) {
50+
&:has(
51+
~ [data-nextjs-error-overlay-nav]
52+
.error-overlay-notch[data-side='right']
53+
) {
4954
border-top-right-radius: 0;
5055
}
5156
}

packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-nav/error-overlay-nav.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function ErrorOverlayNav({
2121
isTurbopack,
2222
}: ErrorOverlayNavProps) {
2323
return (
24-
<div className="error-overlay-nav">
24+
<div data-nextjs-error-overlay-nav>
2525
<Notch side="left">
2626
{/* TODO: better passing data instead of nullish coalescing */}
2727
<ErrorOverlayPagination
@@ -43,7 +43,7 @@ export function ErrorOverlayNav({
4343
}
4444

4545
export const styles = css`
46-
.error-overlay-nav {
46+
[data-nextjs-error-overlay-nav] {
4747
display: flex;
4848
justify-content: space-between;
4949
align-items: center;

test/lib/next-test-utils.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,11 @@ export function getRedboxNavText(browser: BrowserInterface): Promise<string> {
994994
return browser.eval(() => {
995995
const portal = [].slice
996996
.call(document.querySelectorAll('nextjs-portal'))
997-
.find((p) => p.shadowRoot.querySelector('.error-overlay-nav'))
997+
.find((p) =>
998+
p.shadowRoot.querySelector('[data-nextjs-error-overlay-nav]')
999+
)
9981000
const root = portal.shadowRoot
999-
return root.querySelector('.error-overlay-nav')?.innerText
1001+
return root.querySelector('[data-nextjs-error-overlay-nav]')?.innerText
10001002
})
10011003
}
10021004

0 commit comments

Comments
 (0)