Skip to content

Commit

Permalink
Focus tag shortcut name upon tag shortcut creation
Browse files Browse the repository at this point in the history
  • Loading branch information
GeniJaho committed Mar 25, 2024
1 parent bf36d35 commit f669a86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions resources/js/Pages/TagShortcuts/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const props = defineProps({
tags: Object,
});
const tagShortcutModal = ref(null);
const showModal = ref(false);
const search = ref('');
const filteredTagShortcuts = computed(() => {
Expand All @@ -33,6 +34,7 @@ const openModal = (tagShortcut = null) => {
tagShortcutState.value.setTagShortcut(tagShortcut);
tagShortcutState.value.setTagShortcutName(tagShortcut);
showModal.value = true;
tagShortcutModal.value.autofocusName();
};
const closeModal = () => {
Expand Down Expand Up @@ -121,6 +123,7 @@ provide('tags', readonly(props.tags));
</div>

<TagShortcutModal
ref="tagShortcutModal"
:show="showModal"
@close="closeModal"
></TagShortcutModal>
Expand Down
10 changes: 10 additions & 0 deletions resources/js/Pages/TagShortcuts/Partials/TagShortcutModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const props = defineProps({
const items = inject('items');
const tags = inject('tags');
const selectedItem = ref(null);
const shortcutName = ref(null);
const addItem = () => {
axios.post(route('tag-shortcut-items.store', tagShortcutState.value.tagShortcut.id), {
Expand All @@ -45,6 +46,14 @@ const updateName = debounce(() => {
const close = () => {
emit('close');
};
defineExpose({
autofocusName: () => {
if (! tagShortcutState.value.tagShortcut) {
setTimeout(() => shortcutName.value?.focus(), 100)
}
}
});
</script>
<template>
Expand All @@ -67,6 +76,7 @@ const close = () => {
<div class="w-full sm:w-96">
<TextInput
id="shortcut"
ref="shortcutName"
v-model="tagShortcutState.shortcutName"
@input="updateName"
type="text"
Expand Down

0 comments on commit f669a86

Please sign in to comment.