Skip to content

Commit

Permalink
グループ編集時のLineEditorにもつけた
Browse files Browse the repository at this point in the history
  • Loading branch information
mehm8128 committed Nov 3, 2023
1 parent 45a2831 commit 7f79768
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/GroupManager/LineEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div :class="$style.label">{{ label }}</div>
<div v-if="isEditing" :class="$style.inputWrapper">
<form-input
ref="inputRef"
v-model="localValue"
:class="$style.input"
:max-length="maxLength"
Expand Down Expand Up @@ -37,6 +38,7 @@ import AIcon from '/@/components/UI/AIcon.vue'
import { useModelValueSyncer } from '/@/composables/useModelSyncer'
import useLocalInput from '/@/composables/utils/useLocalInput'
import useToggle from '/@/composables/utils/useToggle'
import { ref, nextTick } from 'vue'
const props = defineProps<{
label: string
Expand All @@ -48,6 +50,8 @@ const emit = defineEmits<{
(e: 'update:modelValue', _value: string): void
}>()
const inputRef = ref<InstanceType<typeof FormInput> | null>(null)
const remoteValue = useModelValueSyncer(props, emit)
const { localValue, isEditing } = useLocalInput(
remoteValue,
Expand All @@ -57,7 +61,15 @@ const { localValue, isEditing } = useLocalInput(
},
true // キャンセルするUIがないため
)
const { open: startEditing, close: endEditing } = useToggle(isEditing)
const { open, close: endEditing } = useToggle(isEditing)
const startEditing = async () => {
open()
await nextTick()
if (isEditing.value) {
inputRef.value?.focus()
}
}
</script>

<style lang="scss" module>
Expand Down
2 changes: 2 additions & 0 deletions src/components/UI/FormInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ onMounted(() => {
if (!props.focusOnMount || isTouchDevice()) return
focus()
})
defineExpose({ focus })
</script>

<style lang="scss" module>
Expand Down

0 comments on commit 7f79768

Please sign in to comment.