Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/overlay/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function App({
spotlightEventTarget.removeEventListener('open', onOpen);
spotlightEventTarget.removeEventListener('close', onClose);
};
}, []);
}, [spotlightEventTarget]);

useEffect(() => {
if (!isOpen) {
Expand All @@ -87,7 +87,7 @@ export default function App({
} else {
document.body.style.overflow = 'hidden';
}
}, [isOpen]);
}, [isOpen, spotlightEventTarget]);

log('Integrations', integrationData);

Expand Down
4 changes: 0 additions & 4 deletions packages/overlay/src/components/Debugger.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ReactComponent as Logo } from '~/assets/glyph.svg';
import { Integration, IntegrationData } from '~/integrations/integration';
import classNames from '../lib/classNames';
import useKeyPress from '../lib/useKeyPress';
import Overview from './Overview';

export default function Debugger({
Expand All @@ -18,9 +17,6 @@ export default function Debugger({
integrationData: IntegrationData<unknown>;
isOnline: boolean;
}) {
useKeyPress('Escape', () => {
setOpen(false);
});
return (
<div
className={classNames('fullscreen-blur', isOpen ? '' : '!hidden')}
Expand Down
1 change: 0 additions & 1 deletion packages/overlay/src/components/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { createElement } from 'react';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { Integration, IntegrationData } from '~/integrations/integration';
import Tabs from './Tabs';

export default function Overview({
integrations,
integrationData,
Expand Down
16 changes: 15 additions & 1 deletion packages/overlay/src/components/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { NavLink, useNavigate } from 'react-router-dom';
import { NavLink, useLocation, useNavigate } from 'react-router-dom';
import { type IntegrationTab } from '~/integrations/integration';
import classNames from '../lib/classNames';
import { getSpotlightEventTarget } from '../lib/eventTarget';
import useKeyPress from '../lib/useKeyPress';

export type Props = {
/**
Expand All @@ -18,6 +20,17 @@ export type Props = {

export default function Tabs({ tabs, nested }: Props) {
const navigate = useNavigate();
const location = useLocation();
const spotlightEventTarget = getSpotlightEventTarget();

useKeyPress('Escape', () => {
if (location.pathname.split('/').length === 2) {
spotlightEventTarget.dispatchEvent(new CustomEvent('closed'));
} else {
navigate(-1);
}
});

return (
<div>
<div className="sm:hidden">
Expand Down Expand Up @@ -50,6 +63,7 @@ export default function Tabs({ tabs, nested }: Props) {
<NavLink
to={`${nested ? '' : '/'}${tab.id}`}
key={tab.id}
replace={true}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see this actually solves the problem I mentioned in my review, right?
So we just need to apply it to the respective places

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, might be a bit more delicate there - tried it quickly and didn't work ootb

We could also consider hitting ESC in quick succession closes Spotlight.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, maybe we add another key combination for dedicated open/close functionality? #158

className={({ isActive }) =>
classNames(
isActive
Expand Down