mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-01 21:26:08 +08:00
fix(webui): 底部抽屉打开时不再聚焦第一个输入框
NDrawer 默认把焦点给第一个可聚焦元素,编辑规则抽屉一打开就聚焦标题输入框(手机上会弹出键盘,键盘避让随之把面板上移)。改为关闭 auto-focus,入场后聚焦面板本身,与原 headlessui 行为一致。
This commit is contained in:
@@ -40,6 +40,7 @@ const show = defineModel<boolean>('show', { required: true });
|
||||
|
||||
const titleId = useId();
|
||||
const dragHandleRef = useTemplateRef<HTMLElement>('dragHandle');
|
||||
const panelRef = useTemplateRef<HTMLElement>('panel');
|
||||
const translateY = ref(0);
|
||||
const isDragging = ref(false);
|
||||
const keyboardHeight = ref(0);
|
||||
@@ -127,9 +128,15 @@ function close() {
|
||||
:mask-closable="closeable"
|
||||
:close-on-esc="closeable"
|
||||
:aria-labelledby="title ? titleId : undefined"
|
||||
:auto-focus="false"
|
||||
@after-enter="panelRef?.focus({ preventScroll: true })"
|
||||
@update:show="(value: boolean) => value || close()"
|
||||
>
|
||||
<!-- 焦点给面板本身(与 headlessui 一致不聚焦输入框):NDrawer 默认聚焦
|
||||
第一个输入框,手机上一打开就会弹出键盘 -->
|
||||
<div
|
||||
ref="panel"
|
||||
tabindex="-1"
|
||||
data-testid="bottom-sheet-panel"
|
||||
class="ab-bottom-sheet__panel"
|
||||
:class="{ 'ab-bottom-sheet__panel--fullscreen': fullscreen }"
|
||||
@@ -187,6 +194,7 @@ function close() {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
pointer-events: auto;
|
||||
outline: none;
|
||||
@include safeAreaBottom(padding-bottom);
|
||||
|
||||
// Fallback for browsers that don't support dvh
|
||||
|
||||
Reference in New Issue
Block a user