Skip to content

Commit

Permalink
added comment & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-mereuta committed Dec 17, 2024
1 parent de92116 commit ccd48b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/pagesPanel/Pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ function Pages({ pages, activePageId, pagesToRefresh, setPagesToRefresh }: Pages
return awaitedArray as PageSnapshot[];
}, []);

/**
* by attaching listeners here and not in ShortcutProvider.tsx,
* 'pages' prop that gets populated via 'onPagesChanged' subscriber,
* will not trigger rerenders of ShortcutProvider's children,
* causing multiple query refectch in useMediaDetails
*/
const { handleSelectPage } = useAttachArrowKeysListener({ pages, activePageId });

useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions src/tests/contexts/ShortcutProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('ShortcutProvider', () => {
mockSDK.canvas.setZoomPercentage = jest.fn().mockImplementation().mockReturnValue({ success: true, code: 200 });

window.StudioUISDK = mockSDK;

it('triggers the sandbox toggle shortcut', async () => {
const user = userEvent.setup();
const onSandboxModeToggleFn = jest.fn();
Expand Down

0 comments on commit ccd48b0

Please sign in to comment.