Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): フォーカスの挙動を修正 #14158

Merged
merged 42 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5372b25
fix(frontend): 直前のパターンを記録するように
kakkokari-gtyih Jul 9, 2024
d8cf64a
fix(frontend): フォーカス/タブ移動に関する挙動を調整 (#226)
kakkokari-gtyih Jul 9, 2024
aaf02d5
focusのデザイン修正
kakkokari-gtyih Jul 9, 2024
4340895
move scripts
kakkokari-gtyih Jul 9, 2024
b104485
Modalにfocus trapを追加
kakkokari-gtyih Jul 9, 2024
40a7509
記録するホットキーはレートリミット式にする
kakkokari-gtyih Jul 9, 2024
2a322ed
escキーのハンドリングをMkModalに統一
kakkokari-gtyih Jul 9, 2024
783509f
fix
kakkokari-gtyih Jul 9, 2024
7d56db2
enterで子メニューを開けるように
kakkokari-gtyih Jul 9, 2024
3dcf7da
lint
kakkokari-gtyih Jul 9, 2024
fe046ef
fix focus trap
kakkokari-gtyih Jul 9, 2024
93b2b98
improve switch accessibility
kakkokari-gtyih Jul 9, 2024
8f602b7
一部のmodalのフォーカストラップが外れない問題を修正
kakkokari-gtyih Jul 9, 2024
2a9b8dc
fix
kakkokari-gtyih Jul 9, 2024
33523d8
fix
kakkokari-gtyih Jul 9, 2024
bdac342
Revert "記録するホットキーはレートリミット式にする"
kakkokari-gtyih Jul 9, 2024
a9bb52e
Revert "fix(frontend): 直前のパターンを記録するように"
kakkokari-gtyih Jul 9, 2024
c24be37
Revert "Revert "fix(frontend): 直前のパターンを記録するように""
kakkokari-gtyih Jul 9, 2024
f85c709
Revert "Revert "記録するホットキーはレートリミット式にする""
kakkokari-gtyih Jul 9, 2024
7db27f7
試験的にCypressでのFocustrapを無効化
kakkokari-gtyih Jul 9, 2024
bf542b0
fix
kakkokari-gtyih Jul 9, 2024
4aa49b7
fix focus-trap
kakkokari-gtyih Jul 9, 2024
2f3f678
Update Changelog
kakkokari-gtyih Jul 9, 2024
d356ec8
Merge branch 'develop' into fix-14157
kakkokari-gtyih Jul 9, 2024
eaaee12
:v:
kakkokari-gtyih Jul 9, 2024
cf3e1a8
fix focustrap invocation logic
kakkokari-gtyih Jul 10, 2024
b4b09f7
スクロールがsticky headerを考慮するように
kakkokari-gtyih Jul 10, 2024
afc4f14
:art:
kakkokari-gtyih Jul 10, 2024
9293922
スタイルの微調整
kakkokari-gtyih Jul 10, 2024
2f1760c
:art:
kakkokari-gtyih Jul 10, 2024
a0d748f
remove deprecated key aliases
kakkokari-gtyih Jul 11, 2024
06b7f01
Merge branch 'develop' into fix-14157
kakkokari-gtyih Jul 11, 2024
7dc685b
focusElementが足りなかったので修正
kakkokari-gtyih Jul 11, 2024
7478b71
preview系にfocus時スタイルが足りなかったので修正
kakkokari-gtyih Jul 11, 2024
1f80c08
`returnFocusElement` -> `returnFocusTo`
kakkokari-gtyih Jul 11, 2024
54fd871
lint
kakkokari-gtyih Jul 11, 2024
565bcb5
Update packages/frontend/src/components/MkModalWindow.vue
syuilo Jul 11, 2024
69abbd6
Apply suggestions from code review
kakkokari-gtyih Jul 11, 2024
d278f30
keydownイベントをまとめる
kakkokari-gtyih Jul 11, 2024
4bc2b85
use correct pesudo-element selector
kakkokari-gtyih Jul 11, 2024
dd5da58
fix
kakkokari-gtyih Jul 11, 2024
e1838e6
rename
kakkokari-gtyih Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
### Client
- Enhance: 内蔵APIドキュメントのデザイン・パフォーマンスを改善
- Enhance: 非ログイン時のハイライトTLのデザインを改善
- Enhance: フロントエンドのアクセシビリティ改善
(Based on https://github.com/taiyme/misskey/pull/226)
- Fix: `/about#federation` ページなどで各インスタンスのチャートが表示されなくなっていた問題を修正
- Fix: ユーザーページの追加情報のラベルを投稿者のサーバーの絵文字で表示する (#13968)
- Fix: リバーシの対局を正しく共有できないことがある問題を修正
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/components/MkAchievements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ onMounted(() => {
background: linear-gradient(0deg, #ffee20, #eb7018);
}

&:before {
&::before {
content: "";
display: block;
position: absolute;
Expand All @@ -173,7 +173,7 @@ onMounted(() => {
background: linear-gradient(0deg, #e1e1e1, #7c7c7c);
}

&:before {
&::before {
content: "";
display: block;
position: absolute;
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/src/components/MkButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ function onMousedown(evt: MouseEvent): void {
}

&:focus-visible {
outline: solid 2px var(--focus);
outline-offset: 2px;
}

Expand Down
12 changes: 1 addition & 11 deletions packages/frontend/src/components/MkChannelFollowButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,7 @@ async function onClick() {
}

&:focus-visible {
&:after {
content: "";
pointer-events: none;
position: absolute;
top: -5px;
right: -5px;
bottom: -5px;
left: -5px;
border: 2px solid var(--focus);
border-radius: 32px;
}
outline-offset: 2px;
}

&:hover {
Expand Down
19 changes: 18 additions & 1 deletion packages/frontend/src/components/MkChannelPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<div style="position: relative;">
<MkA :to="`/channels/${channel.id}`" class="eftoefju _panel" tabindex="-1" @click="updateLastReadedAt">
<MkA :to="`/channels/${channel.id}`" class="eftoefju _panel" @click="updateLastReadedAt">
<div class="banner" :style="bannerStyle">
<div class="fade"></div>
<div class="name"><i class="ti ti-device-tv"></i> {{ channel.name }}</div>
Expand Down Expand Up @@ -80,13 +80,30 @@ const bannerStyle = computed(() => {
<style lang="scss" scoped>
.eftoefju {
display: block;
position: relative;
overflow: hidden;
width: 100%;

&:hover {
text-decoration: none;
}

&:focus-within {
outline: none;

&::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: inherit;
pointer-events: none;
box-shadow: inset 0 0 0 2px var(--focus);
}
}

> .banner {
position: relative;
width: 100%;
Expand Down
8 changes: 8 additions & 0 deletions packages/frontend/src/components/MkClipPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ const remaining = computed(() => {
.link {
display: block;

&:focus-visible {
outline: none;

.root {
box-shadow: inset 0 0 0 2px var(--focus);
}
}

&:hover {
text-decoration: none;
color: var(--accent);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:leaveToClass="defaultStore.state.animation ? $style.transition_fade_leaveTo : ''"
>
<div ref="rootEl" :class="$style.root" :style="{ zIndex }" @contextmenu.prevent.stop="() => {}">
<MkMenu :items="items" :align="'left'" @close="$emit('closed')"/>
<MkMenu :items="items" :align="'left'" @close="emit('closed')"/>
</div>
</Transition>
</template>
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/components/MkCwButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ function toggle() {
.label {
margin-left: 4px;

&:before {
&::before {
content: '(';
}

&:after {
&::after {
content: ')';
}
}
Expand Down
16 changes: 2 additions & 14 deletions packages/frontend/src/components/MkDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-->

<template>
<MkModal ref="modal" :preferType="'dialog'" :zPriority="'high'" @click="done(true)" @closed="emit('closed')">
<MkModal ref="modal" :preferType="'dialog'" :zPriority="'high'" @click="done(true)" @closed="emit('closed')" @esc="cancel()">
<div :class="$style.root">
<div v-if="icon" :class="$style.icon">
<i :class="icon"></i>
Expand Down Expand Up @@ -51,7 +51,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import { onBeforeUnmount, onMounted, ref, shallowRef, computed } from 'vue';
import { ref, shallowRef, computed } from 'vue';
import MkModal from '@/components/MkModal.vue';
import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
Expand Down Expand Up @@ -156,25 +156,13 @@ function onBgClick() {
if (props.cancelableByBgClick) cancel();
}
*/
function onKeydown(evt: KeyboardEvent) {
if (evt.key === 'Escape') cancel();
}

function onInputKeydown(evt: KeyboardEvent) {
if (evt.key === 'Enter' && okButtonDisabledReason.value === null) {
evt.preventDefault();
evt.stopPropagation();
ok();
}
}

onMounted(() => {
document.addEventListener('keydown', onKeydown);
});

onBeforeUnmount(() => {
document.removeEventListener('keydown', onKeydown);
});
</script>

<style lang="scss" module>
Expand Down
32 changes: 16 additions & 16 deletions packages/frontend/src/components/MkDrive.file.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ function onDragend() {
background: rgba(#000, 0.05);

> .label {
&:before,
&:after {
&::before,
&::after {
background: #0b65a5;
}

&.red {
&:before,
&:after {
&::before,
&::after {
background: #c12113;
}
}
Expand All @@ -133,14 +133,14 @@ function onDragend() {
background: rgba(#000, 0.1);

> .label {
&:before,
&:after {
&::before,
&::after {
background: #0b588c;
}

&.red {
&:before,
&:after {
&::before,
&::after {
background: #ce2212;
}
}
Expand All @@ -159,8 +159,8 @@ function onDragend() {
}

> .label {
&:before,
&:after {
&::before,
&::after {
display: none;
}
}
Expand All @@ -181,32 +181,32 @@ function onDragend() {
left: 0;
pointer-events: none;

&:before,
&:after {
&::before,
&::after {
content: "";
display: block;
position: absolute;
z-index: 1;
background: #0c7ac9;
}

&:before {
&::before {
top: 0;
left: 57px;
width: 28px;
height: 8px;
}

&:after {
&::after {
top: 57px;
left: 0;
width: 8px;
height: 28px;
}

&.red {
&:before,
&:after {
&::before,
&::after {
background: #c12113;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkDrive.folder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function onContextmenu(ev: MouseEvent) {
cursor: pointer;

&.draghover {
&:after {
&::after {
content: "";
pointer-events: none;
position: absolute;
Expand Down
33 changes: 25 additions & 8 deletions packages/frontend/src/components/MkEmojiPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<div class="omfetrab" :class="['s' + size, 'w' + width, 'h' + height, { asDrawer, asWindow }]" :style="{ maxHeight: maxHeight ? maxHeight + 'px' : undefined }">
<input ref="searchEl" :value="q" class="search" data-prevent-emoji-insert :class="{ filled: q != null && q != '' }" :placeholder="i18n.ts.search" type="search" autocapitalize="off" @input="input()" @paste.stop="paste" @keydown.stop.prevent.enter="onEnter">
<input
ref="searchEl"
:value="q"
class="search"
data-prevent-emoji-insert
:class="{ filled: q != null && q != '' }"
:placeholder="i18n.ts.search"
type="search"
autocapitalize="off"
@input="input()"
@paste.stop="paste"
@keydown="onKeydown"
>
<!-- FirefoxのTabフォーカスが想定外の挙動となるためtabindex="-1"を追加 https://github.com/misskey-dev/misskey/issues/10744 -->
<div ref="emojisEl" class="emojis" tabindex="-1">
<section class="result">
Expand Down Expand Up @@ -139,6 +151,7 @@ const props = withDefaults(defineProps<{

const emit = defineEmits<{
(ev: 'chosen', v: string): void;
(ev: 'esc'): void;
}>();

const searchEl = shallowRef<HTMLInputElement>();
Expand Down Expand Up @@ -433,9 +446,18 @@ function paste(event: ClipboardEvent): void {
}
}

function onEnter(ev: KeyboardEvent) {
function onKeydown(ev: KeyboardEvent) {
if (ev.isComposing || ev.key === 'Process' || ev.keyCode === 229) return;
done();
if (ev.key === 'Enter') {
ev.preventDefault();
ev.stopPropagation();
done();
}
if (ev.key === 'Escape') {
ev.preventDefault();
ev.stopPropagation();
emit('esc');
}
}

function done(query?: string): boolean | void {
Expand Down Expand Up @@ -702,11 +724,6 @@ defineExpose({
border-radius: 4px;
font-size: 24px;

&:focus-visible {
outline: solid 2px var(--focus);
z-index: 1;
}

&:hover {
background: rgba(0, 0, 0, 0.05);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/components/MkEmojiPickerDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:manualShowing="manualShowing"
:src="src"
@click="modal?.close()"
@esc="modal?.close()"
@opening="opening"
@close="emit('close')"
@closed="emit('closed')"
Expand All @@ -28,6 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:asDrawer="type === 'drawer'"
:max-height="maxHeight"
@chosen="chosen"
@esc="modal?.close()"
/>
</MkModal>
</template>
Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/src/components/MkFlashPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-->

<template>
<MkA :to="`/play/${flash.id}`" class="vhpxefrk _panel" tabindex="-1">
<MkA :to="`/play/${flash.id}`" class="vhpxefrk _panel">
<article>
<header>
<h1 :title="flash.title">{{ flash.title }}</h1>
Expand Down Expand Up @@ -39,6 +39,10 @@ const props = defineProps<{
color: var(--accent);
}

&:focus-visible {
outline-offset: -2px;
}

> article {
padding: 16px;

Expand Down
Loading
Loading