From aa662682f3b78a8a34d9434b6132c645810e8d01 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 13 Dec 2019 08:31:05 -0800 Subject: [PATCH] fix: restore focus on community page (#1669) --- .../_components/community/PageListItem.html | 2 +- src/routes/_pages/community/index.html | 152 +++++++++--------- tests/spec/010-focus.js | 14 +- 3 files changed, 92 insertions(+), 76 deletions(-) diff --git a/src/routes/_components/community/PageListItem.html b/src/routes/_components/community/PageListItem.html index ada58682..e4f3453f 100644 --- a/src/routes/_components/community/PageListItem.html +++ b/src/routes/_components/community/PageListItem.html @@ -1,5 +1,5 @@
  • - + {label} diff --git a/src/routes/_pages/community/index.html b/src/routes/_pages/community/index.html index 8350e3e5..c06b26a3 100644 --- a/src/routes/_pages/community/index.html +++ b/src/routes/_pages/community/index.html @@ -1,88 +1,90 @@ {#if $isUserLoggedIn}
    - + + + +

    + Timelines +

    + + + + + + + + + {#if listsLength} + +

    + Lists +

    + + + {#each $lists as list, i} + + {/each} + + + {/if} + +

    - Timelines + Instance settings

    - - + {#if isLockedAccount} + + {/if} + - - - - {#if listsLength} - -

    - Lists -

    - - - {#each $lists as list, i} - - {/each} - - - {/if} - -
    - -

    - Instance settings -

    - - - {#if isLockedAccount} - - {/if} - - - - - +
    {:else} @@ -123,6 +125,7 @@ import RadioGroup from '../../_components/radio/RadioGroup.html' import { updateListsForInstance } from '../../_actions/lists' import { updateFollowRequestCountIfLockedAccount } from '../../_actions/followRequests' + import FocusRestoration from '../../_components/FocusRestoration.html' export default { async oncreate () { @@ -140,7 +143,8 @@ HiddenFromSSR, PageList, PageListItem, - RadioGroup + RadioGroup, + FocusRestoration }, computed: { isLockedAccount: ({ $currentVerifyCredentials }) => $currentVerifyCredentials && $currentVerifyCredentials.locked, diff --git a/tests/spec/010-focus.js b/tests/spec/010-focus.js index 90077aba..008a4166 100644 --- a/tests/spec/010-focus.js +++ b/tests/spec/010-focus.js @@ -14,7 +14,7 @@ import { getActiveElementTagName, getActiveElementClassList, getNthStatusSensitiveMediaButton, - getActiveElementAriaLabel, settingsNavButton, getActiveElementHref + getActiveElementAriaLabel, settingsNavButton, getActiveElementHref, communityNavButton } from '../utils' import { loginAsFoobar } from '../roles' import { Selector as $ } from 'testcafe' @@ -182,3 +182,15 @@ test('preserves focus on settings page', async t => { .expect(getActiveElementHref()).eql('/settings') .expect(getActiveElementClassList()).contains('settings-nav-item') }) + +test('preserves focus on community page', async t => { + await loginAsFoobar(t) + await t + .click(communityNavButton) + .expect(getUrl()).contains('/community') + .click($('a[href="/federated"]')) + .expect(getUrl()).contains('/federated') + await goBack() + await t + .expect(getActiveElementHref()).eql('/federated') +})