Skip to content

Commit 8626b92

Browse files
committed
v4.19.2: vf-smart-select updates
1 parent 02852e1 commit 8626b92

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@signal24/vue-foundation",
33
"type": "module",
4-
"version": "4.19.1",
4+
"version": "4.19.2",
55
"description": "Common components, directives, and helpers for Vue 3 apps",
66
"module": "./dist/vue-foundation.es.js",
77
"exports": {

src/components/vf-alert-modal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<Modal :class="['vf-alert', ...(classes ?? [])]">
33
<template v-if="title" #header>
4-
<h1>{{ title }}</h1>
4+
{{ title }}
55
</template>
66

77
<div v-if="isHtml" :innerHtml="message" class="user-message"></div>

src/components/vf-smart-select.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const props = defineProps<{
8181
optionsListId?: string;
8282
debug?: boolean;
8383
required?: boolean;
84+
showCreateTextOnNewItem?: boolean;
8485
}>();
8586
8687
const emit = defineEmits<{
@@ -106,6 +107,7 @@ const selectedOptionTitle = ref<string | null>(null);
106107
const shouldDisplayOptions = ref(false);
107108
const highlightedOptionKey = ref<string | symbol | null>(null);
108109
const shouldShowCreateOption = ref(false);
110+
const shouldShowCreateTextOnNewItem = computed(() => props.showCreateTextOnNewItem ?? true);
109111
110112
const effectivePrependOptions = computed(() => props.prependOptions ?? []);
111113
const effectiveAppendOptions = computed(() => props.appendOptions ?? []);
@@ -190,7 +192,9 @@ const effectiveOptions = computed(() => {
190192
if (!hasExactMatch) {
191193
options.push({
192194
key: CreateSymbol,
193-
title: 'Create <strong>' + searchText.value.trim() + '</strong>...'
195+
title: shouldShowCreateTextOnNewItem.value
196+
? 'Create <strong>' + searchText.value.trim() + '</strong>...'
197+
: searchText.value.trim()
194198
});
195199
}
196200
}
@@ -303,6 +307,7 @@ function handleKeyDown(e: KeyboardEvent) {
303307
if (e.key == 'Escape') {
304308
e.stopPropagation();
305309
(e.target as HTMLInputElement).blur();
310+
focusNextInput();
306311
return;
307312
}
308313
@@ -496,6 +501,7 @@ function selectOption(option: OptionDescriptor) {
496501
}
497502
498503
searchField.value?.blur();
504+
focusNextInput();
499505
}
500506
501507
function handleValueChanged() {
@@ -515,6 +521,21 @@ function handleValueChanged() {
515521
function addRemoteOption(option: T) {
516522
loadedOptions.value.unshift(option);
517523
}
524+
525+
function focusNextInput() {
526+
let parent = el.value?.parentElement;
527+
while (parent && parent.tagName !== 'FORM' && parent.tagName !== 'BODY') {
528+
parent = parent.parentElement;
529+
}
530+
if (!parent) return;
531+
532+
const allFocusableElements = parent.querySelectorAll('input, button, textarea, select, [tabindex]:not([tabindex="-1"])');
533+
if (!allFocusableElements) return;
534+
535+
const currentInputIndex = Array.from(allFocusableElements).findIndex(el => el === searchField.value);
536+
const nextInput = allFocusableElements[currentInputIndex + 1] as HTMLElement;
537+
if (nextInput) setTimeout(() => nextInput.focus(), 0);
538+
}
518539
</script>
519540

520541
<style lang="scss">

0 commit comments

Comments
 (0)