From 6d8f70e2d678a142ff2913f3713fe3f0ce50c54c Mon Sep 17 00:00:00 2001 From: Jesse Pinho Date: Tue, 23 Apr 2024 16:47:16 -0700 Subject: [PATCH 1/2] Fix issue with shifting account header --- .../ui/components/ui/account-switcher.tsx | 64 +++++++++---------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/packages/ui/components/ui/account-switcher.tsx b/packages/ui/components/ui/account-switcher.tsx index 6b58b655b0..a56e461367 100644 --- a/packages/ui/components/ui/account-switcher.tsx +++ b/packages/ui/components/ui/account-switcher.tsx @@ -50,29 +50,26 @@ export const AccountSwitcher = ({ } }; - const shouldShowPreviousButton = + const previousButtonEnabled = account !== 0 && (!sortedFilter || sortedFilter.indexOf(account) > 0); - const shouldShowNextButton = + const nextButtonEnabled = account !== MAX_INDEX && (!sortedFilter || sortedFilter.indexOf(account) < sortedFilter.length - 1); return (
- {shouldShowPreviousButton ? ( - - ) : ( - - )} +
Account @@ -109,24 +106,21 @@ export const AccountSwitcher = ({
- {shouldShowNextButton ? ( - - ) : ( - - )} + ); }; From cfe03d0187147162a1b4927fd17a59d70db15145 Mon Sep 17 00:00:00 2001 From: Jesse Pinho Date: Tue, 23 Apr 2024 16:56:51 -0700 Subject: [PATCH 2/2] Update tests --- .../ui/components/ui/account-switcher.test.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/ui/components/ui/account-switcher.test.tsx b/packages/ui/components/ui/account-switcher.test.tsx index a188a5295c..d7917b1be4 100644 --- a/packages/ui/components/ui/account-switcher.test.tsx +++ b/packages/ui/components/ui/account-switcher.test.tsx @@ -56,10 +56,10 @@ describe('', () => { expect(onChange).toHaveBeenCalledWith(122); }); - it("does not render when we're at account 0", () => { + it("is disabled when we're at account 0", () => { const { queryByLabelText } = render(); - expect(queryByLabelText('Previous account')).toBeNull(); + expect(queryByLabelText('Previous account')?.parentElement).toBeDisabled(); }); describe('when a filter has been passed', () => { @@ -74,12 +74,12 @@ describe('', () => { expect(onChange).toHaveBeenCalledWith(100); }); - it("does not render when we're at the lowest account index in the filter", () => { + it("is disabled when we're at the lowest account index in the filter", () => { const { queryByLabelText } = render( , ); - expect(queryByLabelText('Previous account')).toBeNull(); + expect(queryByLabelText('Previous account')?.parentElement).toBeDisabled(); }); }); }); @@ -94,10 +94,10 @@ describe('', () => { expect(onChange).toHaveBeenCalledWith(124); }); - it("does not render when we're at the maximum account index", () => { + it("is disabled when we're at the maximum account index", () => { const { queryByLabelText } = render(); - expect(queryByLabelText('Next account')).toBeNull(); + expect(queryByLabelText('Next account')?.parentElement).toBeDisabled(); }); describe('when a filter has been passed', () => { @@ -112,12 +112,12 @@ describe('', () => { expect(onChange).toHaveBeenCalledWith(123); }); - it("does not render when we're at the highest account index in the filter", () => { + it("is disabled when we're at the highest account index in the filter", () => { const { queryByLabelText } = render( , ); - expect(queryByLabelText('Next account')).toBeNull(); + expect(queryByLabelText('Next account')?.parentElement).toBeDisabled(); }); }); });