From 29f3374c6169f2827eb2e159fd48d0c7275bc2ba Mon Sep 17 00:00:00 2001 From: Maciek Date: Wed, 23 Aug 2023 09:23:36 +0200 Subject: [PATCH] fix(trading): fix hidden sidebars on load (#4583) --- .../trading-deal-ticket-basics.cy.ts | 9 ++++++ apps/trading/components/sidebar/sidebar.tsx | 31 ++++++------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-basics.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-basics.cy.ts index 57254632d..0b2d1036a 100644 --- a/apps/trading-e2e/src/integration/trading-deal-ticket-basics.cy.ts +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-basics.cy.ts @@ -54,6 +54,15 @@ describe('deal ticket basics', { tags: '@smoke' }, () => { cy.getByTestId(toggleLimit).next('input').should('be.checked'); cy.getByTestId(orderPriceField).should('have.value', '101'); }); + + it('sidebar should be open after reload', () => { + cy.mockTradingPage(); + cy.getByTestId('deal-ticket-form').should('be.visible'); + cy.getByTestId('Order').click(); + cy.getByTestId('deal-ticket-form').should('not.exist'); + cy.reload(); + cy.getByTestId('deal-ticket-form').should('be.visible'); + }); }); describe( diff --git a/apps/trading/components/sidebar/sidebar.tsx b/apps/trading/components/sidebar/sidebar.tsx index 2dcf8d4a8..d32d0d8d0 100644 --- a/apps/trading/components/sidebar/sidebar.tsx +++ b/apps/trading/components/sidebar/sidebar.tsx @@ -14,12 +14,9 @@ import { Settings } from '../settings'; import { Tooltip } from '../../components/tooltip'; import { WithdrawContainer } from '../withdraw-container'; import { Routes as AppRoutes } from '../../pages/client-router'; -import { persist } from 'zustand/middleware'; import { GetStarted } from '../welcome-dialog'; import { useVegaWallet, useViewAsDialog } from '@vegaprotocol/wallet'; -const STORAGE_KEY = 'vega_sidebar_store'; - export enum ViewType { Order = 'Order', Info = 'Info', @@ -302,22 +299,14 @@ export const useSidebar = create<{ init: boolean; view: SidebarView | null; setView: (view: SidebarView | null) => void; -}>()( - persist( - (set) => ({ - init: true, - view: null, - setView: (x) => - set(() => { - if (x == null) { - return { view: null, init: false }; - } - - return { view: x, init: false }; - }), +}>()((set) => ({ + init: true, + view: null, + setView: (x) => + set(() => { + if (x == null) { + return { view: null, init: false }; + } + return { view: x, init: false }; }), - { - name: STORAGE_KEY, - } - ) -); +}));