Skip to content

Commit ab65c60

Browse files
NicoHinderlingclaudeClaude Opus 4.6
authored
feat(dashboards): Add ESC key to dismiss widget builder slideout (#112186)
Pressing Escape while the widget builder slideout is open now triggers the same close flow as the Close button. If there are unsaved changes, the confirmation modal appears; otherwise the panel closes immediately. Previously there was no keyboard shortcut to dismiss the slideout — you had to click the Close or Cancel buttons. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Claude Opus 4.6 <noreply@example.com>
1 parent 8ed40af commit ab65c60

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

static/app/views/dashboards/widgetBuilder/components/widgetBuilderSlideout.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import isEqual from 'lodash/isEqual';
1212

1313
import {Alert} from '@sentry/scraps/alert';
1414
import {Button} from '@sentry/scraps/button';
15+
import {useHotkeys} from '@sentry/scraps/hotkey';
1516
import {Flex} from '@sentry/scraps/layout';
1617
import {ExternalLink, Link} from '@sentry/scraps/link';
1718
import {SlideOverPanel} from '@sentry/scraps/slideOverPanel';
1819

1920
import {Breadcrumbs} from 'sentry/components/breadcrumbs';
2021
import {openConfirmModal} from 'sentry/components/confirm';
2122
import {ErrorBoundary} from 'sentry/components/errorBoundary';
23+
import {useGlobalModal} from 'sentry/components/globalModal/useGlobalModal';
2224
import {Placeholder} from 'sentry/components/placeholder';
2325
import {IconClose} from 'sentry/icons';
2426
import {t, tctCode} from 'sentry/locale';
@@ -99,6 +101,7 @@ export function WidgetBuilderSlideout({
99101
}: WidgetBuilderSlideoutProps) {
100102
const organization = useOrganization();
101103
const location = useLocation();
104+
const {visible: isModalVisible} = useGlobalModal();
102105
const {state, dispatch} = useWidgetBuilderContext();
103106
const [initialState] = useState(state);
104107
const [customizeFromLibrary, setCustomizeFromLibrary] = useState(false);
@@ -234,6 +237,19 @@ export function WidgetBuilderSlideout({
234237
});
235238
}, [initialState, onClose, state]);
236239

240+
useHotkeys([
241+
{
242+
match: 'Escape',
243+
skipPreventDefault: true,
244+
callback: (evt: KeyboardEvent) => {
245+
if (!isModalVisible) {
246+
evt.preventDefault();
247+
onCloseWithModal();
248+
}
249+
},
250+
},
251+
]);
252+
237253
const breadcrumbs = customizeFromLibrary
238254
? [
239255
{

0 commit comments

Comments
 (0)