fix: restore focus on community page (#1669)
This commit is contained in:
parent
47ade12167
commit
aa662682f3
|
@ -1,5 +1,5 @@
|
||||||
<li class="page-list-item">
|
<li class="page-list-item">
|
||||||
<a {href} rel="prefetch">
|
<a {href} rel="prefetch" id="page-list-item-{href}">
|
||||||
<SvgIcon className="page-list-item-svg" href={icon} />
|
<SvgIcon className="page-list-item-svg" href={icon} />
|
||||||
<span aria-label={ariaLabel}>
|
<span aria-label={ariaLabel}>
|
||||||
{label}
|
{label}
|
||||||
|
|
|
@ -1,88 +1,90 @@
|
||||||
{#if $isUserLoggedIn}
|
{#if $isUserLoggedIn}
|
||||||
<div class="community-page">
|
<div class="community-page">
|
||||||
|
|
||||||
<RadioGroup
|
<FocusRestoration realm="community">
|
||||||
id="pinnables"
|
<RadioGroup
|
||||||
length={numPinnable}
|
id="pinnables"
|
||||||
label="Pinnable timelines">
|
length={numPinnable}
|
||||||
|
label="Pinnable timelines">
|
||||||
|
|
||||||
|
<h2 class="community-header">
|
||||||
|
Timelines
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<PageList label="Timelines">
|
||||||
|
<PageListItem href="/local"
|
||||||
|
label="Local Timeline"
|
||||||
|
icon="#fa-users"
|
||||||
|
pinnable="true"
|
||||||
|
pinIndex={0}
|
||||||
|
/>
|
||||||
|
<PageListItem href="/federated"
|
||||||
|
label="Federated Timeline"
|
||||||
|
icon="#fa-globe"
|
||||||
|
pinnable="true"
|
||||||
|
pinIndex={1}
|
||||||
|
/>
|
||||||
|
<PageListItem href="/favorites"
|
||||||
|
label="Favorites"
|
||||||
|
icon="#fa-star"
|
||||||
|
pinnable="true"
|
||||||
|
pinIndex={2}
|
||||||
|
/>
|
||||||
|
<PageListItem href="/direct"
|
||||||
|
label="Direct messages"
|
||||||
|
icon="#fa-envelope"
|
||||||
|
pinnable="true"
|
||||||
|
pinIndex={3}
|
||||||
|
/>
|
||||||
|
</PageList>
|
||||||
|
|
||||||
|
{#if listsLength}
|
||||||
|
|
||||||
|
<h2 class="community-header">
|
||||||
|
Lists
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<PageList label="Lists">
|
||||||
|
{#each $lists as list, i}
|
||||||
|
<PageListItem href="/lists/{list.id}"
|
||||||
|
label={list.title}
|
||||||
|
icon="#fa-bars"
|
||||||
|
pinnable="true"
|
||||||
|
pinIndex={4 + i}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</PageList>
|
||||||
|
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
<h2 class="community-header">
|
<h2 class="community-header">
|
||||||
Timelines
|
Instance settings
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<PageList label="Timelines">
|
<PageList label="Instance settings">
|
||||||
<PageListItem href="/local"
|
{#if isLockedAccount}
|
||||||
label="Local Timeline"
|
<PageListItem href="/requests"
|
||||||
icon="#fa-users"
|
label={followRequestsLabel}
|
||||||
pinnable="true"
|
icon="#fa-user-plus"
|
||||||
pinIndex={0}
|
/>
|
||||||
|
{/if}
|
||||||
|
<PageListItem href="/muted"
|
||||||
|
label="Muted users"
|
||||||
|
icon="#fa-volume-off"
|
||||||
/>
|
/>
|
||||||
<PageListItem href="/federated"
|
<PageListItem href="/blocked"
|
||||||
label="Federated Timeline"
|
label="Blocked users"
|
||||||
icon="#fa-globe"
|
icon="#fa-ban"
|
||||||
pinnable="true"
|
|
||||||
pinIndex={1}
|
|
||||||
/>
|
/>
|
||||||
<PageListItem href="/favorites"
|
<PageListItem href="/pinned"
|
||||||
label="Favorites"
|
label="Pinned toots"
|
||||||
icon="#fa-star"
|
icon="#fa-thumb-tack"
|
||||||
pinnable="true"
|
|
||||||
pinIndex={2}
|
|
||||||
/>
|
|
||||||
<PageListItem href="/direct"
|
|
||||||
label="Direct messages"
|
|
||||||
icon="#fa-envelope"
|
|
||||||
pinnable="true"
|
|
||||||
pinIndex={3}
|
|
||||||
/>
|
/>
|
||||||
</PageList>
|
</PageList>
|
||||||
|
|
||||||
{#if listsLength}
|
</FocusRestoration>
|
||||||
|
|
||||||
<h2 class="community-header">
|
|
||||||
Lists
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<PageList label="Lists">
|
|
||||||
{#each $lists as list, i}
|
|
||||||
<PageListItem href="/lists/{list.id}"
|
|
||||||
label={list.title}
|
|
||||||
icon="#fa-bars"
|
|
||||||
pinnable="true"
|
|
||||||
pinIndex={4 + i}
|
|
||||||
/>
|
|
||||||
{/each}
|
|
||||||
</PageList>
|
|
||||||
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
</RadioGroup>
|
|
||||||
|
|
||||||
<h2 class="community-header">
|
|
||||||
Instance settings
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<PageList label="Instance settings">
|
|
||||||
{#if isLockedAccount}
|
|
||||||
<PageListItem href="/requests"
|
|
||||||
label={followRequestsLabel}
|
|
||||||
icon="#fa-user-plus"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
<PageListItem href="/muted"
|
|
||||||
label="Muted users"
|
|
||||||
icon="#fa-volume-off"
|
|
||||||
/>
|
|
||||||
<PageListItem href="/blocked"
|
|
||||||
label="Blocked users"
|
|
||||||
icon="#fa-ban"
|
|
||||||
/>
|
|
||||||
<PageListItem href="/pinned"
|
|
||||||
label="Pinned toots"
|
|
||||||
icon="#fa-thumb-tack"
|
|
||||||
/>
|
|
||||||
</PageList>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<HiddenFromSSR>
|
<HiddenFromSSR>
|
||||||
|
@ -123,6 +125,7 @@
|
||||||
import RadioGroup from '../../_components/radio/RadioGroup.html'
|
import RadioGroup from '../../_components/radio/RadioGroup.html'
|
||||||
import { updateListsForInstance } from '../../_actions/lists'
|
import { updateListsForInstance } from '../../_actions/lists'
|
||||||
import { updateFollowRequestCountIfLockedAccount } from '../../_actions/followRequests'
|
import { updateFollowRequestCountIfLockedAccount } from '../../_actions/followRequests'
|
||||||
|
import FocusRestoration from '../../_components/FocusRestoration.html'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async oncreate () {
|
async oncreate () {
|
||||||
|
@ -140,7 +143,8 @@
|
||||||
HiddenFromSSR,
|
HiddenFromSSR,
|
||||||
PageList,
|
PageList,
|
||||||
PageListItem,
|
PageListItem,
|
||||||
RadioGroup
|
RadioGroup,
|
||||||
|
FocusRestoration
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isLockedAccount: ({ $currentVerifyCredentials }) => $currentVerifyCredentials && $currentVerifyCredentials.locked,
|
isLockedAccount: ({ $currentVerifyCredentials }) => $currentVerifyCredentials && $currentVerifyCredentials.locked,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
getActiveElementTagName,
|
getActiveElementTagName,
|
||||||
getActiveElementClassList,
|
getActiveElementClassList,
|
||||||
getNthStatusSensitiveMediaButton,
|
getNthStatusSensitiveMediaButton,
|
||||||
getActiveElementAriaLabel, settingsNavButton, getActiveElementHref
|
getActiveElementAriaLabel, settingsNavButton, getActiveElementHref, communityNavButton
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { loginAsFoobar } from '../roles'
|
import { loginAsFoobar } from '../roles'
|
||||||
import { Selector as $ } from 'testcafe'
|
import { Selector as $ } from 'testcafe'
|
||||||
|
@ -182,3 +182,15 @@ test('preserves focus on settings page', async t => {
|
||||||
.expect(getActiveElementHref()).eql('/settings')
|
.expect(getActiveElementHref()).eql('/settings')
|
||||||
.expect(getActiveElementClassList()).contains('settings-nav-item')
|
.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')
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue