Skip to content

Commit fdea552

Browse files
authored
fix: allow escape to clear/hide search results (#12756)
closes #12750
1 parent f77582e commit fdea552

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
2-
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
32
import {TriangleRightIcon} from '@radix-ui/react-icons';
3+
import * as Popover from '@radix-ui/react-popover';
44
import {Box, Button, Theme} from '@radix-ui/themes';
55
import Link from 'next/link';
66

@@ -19,8 +19,8 @@ export function MobileMenu({pathname, searchPlatforms}: Props) {
1919
return (
2020
<div className="flex gap-6 items-center">
2121
<ThemeToggle />
22-
<DropdownMenu.Root>
23-
<DropdownMenu.Trigger asChild>
22+
<Popover.Root>
23+
<Popover.Trigger asChild>
2424
<Button
2525
variant="ghost"
2626
size="4"
@@ -31,33 +31,33 @@ export function MobileMenu({pathname, searchPlatforms}: Props) {
3131
Menu
3232
<TriangleRightIcon />
3333
</Button>
34-
</DropdownMenu.Trigger>
34+
</Popover.Trigger>
3535

36-
<DropdownMenu.Portal>
36+
<Popover.Portal>
3737
<Theme accentColor="iris">
38-
<DropdownMenu.Content className={styles.DropdownMenuContent} sideOffset={5}>
38+
<Popover.Content className={styles.PopoverContent} sideOffset={5}>
3939
<Box display={{xs: 'block', sm: 'none'}}>
40-
<DropdownMenu.Item className={styles.DropdownMenuItem} asChild>
40+
<li className={styles.MenuItem}>
4141
<Search path={pathname} searchPlatforms={searchPlatforms} />
42-
</DropdownMenu.Item>
43-
<DropdownMenu.Separator className={styles.DropdownMenuSeparator} />
42+
</li>
43+
<div className={styles.MenuSeparator} />
4444
</Box>
45-
<DropdownMenu.Item className={styles.DropdownMenuItem} asChild>
45+
<li className={styles.MenuItem}>
4646
<Link href="https://sentry.io/changelog/">Changelog</Link>
47-
</DropdownMenu.Item>
48-
<DropdownMenu.Item className={styles.DropdownMenuItem} asChild>
47+
</li>
48+
<li className={styles.MenuItem}>
4949
<Link href="https://try.sentry-demo.com/demo/start/">Sandbox</Link>
50-
</DropdownMenu.Item>
51-
<DropdownMenu.Item className={styles.DropdownMenuItem} asChild>
50+
</li>
51+
<li className={styles.MenuItem}>
5252
<Link href="https://sentry.io/">Go to Sentry</Link>
53-
</DropdownMenu.Item>
54-
<DropdownMenu.Item className={styles.DropdownMenuItem} asChild>
53+
</li>
54+
<li className={styles.MenuItem}>
5555
<Link href="https://sentry.io/signup/">Get Started</Link>
56-
</DropdownMenu.Item>
57-
</DropdownMenu.Content>
56+
</li>
57+
</Popover.Content>
5858
</Theme>
59-
</DropdownMenu.Portal>
60-
</DropdownMenu.Root>
59+
</Popover.Portal>
60+
</Popover.Root>
6161
</div>
6262
);
6363
}

src/components/mobileMenu/styles.module.scss

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
:global(.dark) {
2-
.DropdownMenuContent,
3-
.DropdownMenuSubContent {
2+
.PopoverContent {
43
background-color: var(--gray-2);
54
}
6-
.DropdownMenuItem[data-highlighted],
7-
.DropdownMenuSeparator {
5+
.MenuItem[data-highlighted],
6+
.PopoverSeparator {
87
background-color: var(--gray-4);
98
}
10-
.DropdownMenuItem {
9+
.MenuItem {
1110
color: var(--foreground-primary);
1211
}
1312
}
1413

15-
.DropdownMenuContent,
16-
.DropdownMenuSubContent {
14+
.PopoverContent {
1715
// the portal is rendered outside the area where the font is defined
1816
font-family: var(--font-rubik);
1917
box-sizing: border-box;
@@ -28,7 +26,7 @@
2826

2927
@media screen and (max-width: 768px) {
3028
padding: 1rem;
31-
width: var(--radix-dropdown-menu-content-available-width);
29+
width: var(--radix-popover-content-available-width);
3230

3331
input {
3432
padding: 0.5rem 1rem;
@@ -40,25 +38,23 @@
4038
}
4139
}
4240

43-
.DropdownMenuContent[data-side='top'],
44-
.DropdownMenuSubContent[data-side='top'] {
41+
.PopoverContent[data-side='top'] {
4542
animation-name: slideDownAndFade;
4643
}
4744

48-
.DropdownMenuContent[data-side='right'],
49-
.DropdownMenuSubContent[data-side='right'] {
45+
.PopoverContent[data-side='right'] {
5046
animation-name: slideLeftAndFade;
5147
}
5248

53-
.DropdownMenuContent[data-side='bottom'] {
49+
.PopoverContent[data-side='bottom'] {
5450
animation-name: slideUpAndFade;
5551
}
5652

57-
.DropdownMenuContent[data-side='left'] {
53+
.PopoverContent[data-side='left'] {
5854
animation-name: slideRightAndFade;
5955
}
6056

61-
.DropdownMenuItem {
57+
.MenuItem {
6258
text-decoration: none;
6359
font-weight: 500;
6460
font-size: 1rem;
@@ -72,16 +68,23 @@
7268
position: relative;
7369
user-select: none;
7470
outline: none;
71+
a {
72+
text-decoration: none !important;
73+
color: var(--darkPurple);
74+
}
75+
> div {
76+
width: 100%;
77+
}
7578
}
7679

77-
.DropdownMenuItem[data-highlighted] {
80+
.MenuItem[data-highlighted] {
7881
background-color: var(--accent-purple-light);
7982
}
8083

81-
.DropdownMenuSeparator {
84+
.MenuSeparator {
8285
height: 1px;
83-
background-color: var(--accent-purple-light);
84-
margin-top: 0.75rem;
86+
background-color: var(--gray-4);
87+
margin-top: 1.5rem;
8588
margin-bottom: 0.75rem;
8689
margin-left: 1rem;
8790
margin-right: 1rem;

src/components/search/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,6 @@ export function Search({
299299
onChange={({target: {value}}) => searchFor(value)}
300300
onFocus={() => setInputFocus(true)}
301301
ref={inputRef}
302-
onKeyDown={ev => {
303-
ev.stopPropagation();
304-
}}
305302
/>
306303
<kbd className={styles['search-hotkey']} data-focused={inputFocus}>
307304
{inputFocus ? 'esc' : '⌘K'}

0 commit comments

Comments
 (0)