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();
});
});
});
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 ? (
-
- ) : (
-
- )}
+
);
};