diff --git a/.changeset/famous-cats-play.md b/.changeset/famous-cats-play.md new file mode 100644 index 00000000..e70f4146 --- /dev/null +++ b/.changeset/famous-cats-play.md @@ -0,0 +1,5 @@ +--- +'xstate-viz-app': patch +--- + +Fixed an issue with right-side panels getting cut off after stretching them and shrinking back with the resize handle. diff --git a/cypress/integration/visual.spec.ts b/cypress/integration/visual.spec.ts index b59a5873..302bede0 100644 --- a/cypress/integration/visual.spec.ts +++ b/cypress/integration/visual.spec.ts @@ -32,6 +32,24 @@ describe('Visual', () => { }); }); + it('should have login button in the viewport after the right panel gets stretched and shrinked again', () => { + cy.visit('/viz'); + + cy.getMonacoEditor(); + + cy.getResizeHandle().realSwipe('toLeft', { + length: 100, + }); + + cy.getResizeHandle().realSwipe('toRight', { + length: 100, + }); + + cy.findByRole('button', { name: 'Login' }).then(($button) => { + expect(isInViewport($button)).to.be.true; + }); + }); + it('should have editor buttons aligned vertically with canvas buttons', () => { cy.visit('/viz'); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 939005f2..03701c3a 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -174,6 +174,10 @@ const getControlButtons = () => { return cy.findByTestId('controls'); }; +const getResizeHandle = () => { + return cy.findByTestId('resize-handle'); +}; + type DeepPartial = T extends Function ? T : T extends Array @@ -220,6 +224,8 @@ declare global { getCanvasGraph: typeof getCanvasGraph; getControlButtons: typeof getControlButtons; + + getResizeHandle: typeof getResizeHandle; } } } @@ -236,3 +242,4 @@ Cypress.Commands.add('getCanvasHeader', getCanvasHeader); Cypress.Commands.add('getStatePanel', getStatePanel); Cypress.Commands.add('getCanvasGraph', getCanvasGraph); Cypress.Commands.add('getControlButtons', getControlButtons); +Cypress.Commands.add('getResizeHandle', getResizeHandle); diff --git a/src/EditorPanel.tsx b/src/EditorPanel.tsx index ad9f7a92..100cd280 100644 --- a/src/EditorPanel.tsx +++ b/src/EditorPanel.tsx @@ -140,12 +140,13 @@ const editorPanelMachine = editorPanelModel.createMachine( src: async (ctx) => { const monaco = ctx.monacoRef!; const uri = monaco.Uri.parse(ctx.mainFile); - const getWorker = await monaco.languages.typescript.getTypeScriptWorker(); + const getWorker = + await monaco.languages.typescript.getTypeScriptWorker(); const tsWorker = await getWorker(uri); - const usedXStateGistIdentifiers: string[] = await (tsWorker as any).queryXStateGistIdentifiers( - uri.toString(), - ); + const usedXStateGistIdentifiers: string[] = await ( + tsWorker as any + ).queryXStateGistIdentifiers(uri.toString()); if (usedXStateGistIdentifiers.length > 0) { const fixupImportsText = buildGistFixupImportsText( @@ -436,7 +437,7 @@ export const EditorPanel: React.FC<{ {simulationMode === 'visualizing' && ( <> {/* This extra div acts as a placeholder that is supposed to stretch while EditorWithXStateImports lazy-loads (thanks to `1fr` on the grid) */} -
+
{ diff --git a/src/ResizableBox.tsx b/src/ResizableBox.tsx index 9eab8384..c5b38b0c 100644 --- a/src/ResizableBox.tsx +++ b/src/ResizableBox.tsx @@ -64,6 +64,7 @@ const ResizeHandle: React.FC<{ return ( { send(dragDropModel.events['DRAG.END']()); }} + onPointerCancel={() => { + send(dragDropModel.events['DRAG.END']()); + }} > ); }; @@ -120,9 +124,11 @@ export const ResizableBox: React.FC = ({ // into multiple lines {children} {!disabled && setWidthDelta(value)} />}