Skip to content

Commit 9953c2c

Browse files
committed
fix: a11y for title customization
1 parent 26b8445 commit 9953c2c

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/renderer/components/TabItem.vue

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ function customize() {
9090
isCustomizing = false
9191
}
9292
93+
function resetTitle() {
94+
customTitle = title
95+
isCustomizing = false
96+
}
97+
9398
function autoselect(event: FocusEvent) {
9499
(event.target as HTMLInputElement).select()
95100
}
@@ -135,17 +140,17 @@ function close() {
135140
/>
136141
<VisualIcon v-else-if="pane && tab!.shell" name="lucide-file" class="tab-icon" />
137142
<VisualIcon v-else name="lucide-terminal" class="tab-icon" />
138-
<input
139-
v-if="isCustomizing"
140-
ref="customTitleElement"
141-
v-model="customTitle"
142-
autofocus
143-
class="custom-tab-name"
144-
@focus="autoselect"
145-
@blur="customize"
146-
@keydown.enter="customize"
147-
@keydown.esc="customize"
148-
>
143+
<form v-if="isCustomizing" class="tab-name-form" @submit.prevent="customize">
144+
<input
145+
ref="customTitleElement"
146+
v-model="customTitle"
147+
autofocus
148+
class="custom-tab-name"
149+
@focus="autoselect"
150+
@blur="customize"
151+
@keydown.esc="resetTitle"
152+
>
153+
</form>
149154
<span v-else class="tab-name" @click="startCustomization">{{ customTitle }}</span>
150155
</div>
151156
<div class="right-side">
@@ -211,6 +216,11 @@ function close() {
211216
overflow: hidden;
212217
transition: color 0.2s;
213218
}
219+
.tab-name-form {
220+
display: flex;
221+
flex: 1;
222+
min-width: 0;
223+
}
214224
.custom-tab-name {
215225
flex: 1;
216226
min-width: 0;

0 commit comments

Comments
 (0)