FIX: Profile name button submit

This commit is contained in:
Robert Kossessa
2024-01-30 11:52:48 +01:00
parent cfd0fe80a9
commit d9cbf67867
3 changed files with 12 additions and 4 deletions

View File

@@ -14,7 +14,7 @@
<p class="text-xs text-muted-foreground"> <p class="text-xs text-muted-foreground">
<ScrambleText <ScrambleText
ref="zerooneSubtitle" ref="zerooneSubtitle"
text="Haptic Configuration Tool" scramble-on-mount :scramble-amount="1" :fill-interval="35" text="Haptics Configurator" scramble-on-mount :scramble-amount="1" :fill-interval="35"
:replace-interval="40" /> :replace-interval="40" />
</p> </p>
</div> </div>

View File

@@ -9,7 +9,7 @@
<div <div
class="flex bg-cover mb-6 w-72 aspect-square" class="flex bg-cover mb-6 w-72 aspect-square"
style="background-image: url(src/assets/gui-ico/xl-bg-ico.svg)"> style="background-image: url(src/assets/gui-ico/xl-bg-ico.svg)">
<div class="flex flex-col w-full justify-center p-10 rounded-full overflow-hidden"> <div class="flex flex-col w-full justify-center m-9 rounded-full overflow-hidden">
<div class="self-center w-8 mb-1 opacity-50"> <div class="self-center w-8 mb-1 opacity-50">
<img src="@/assets/gui-ico/ico-midi-logo.svg" alt="midi-logo"> <img src="@/assets/gui-ico/ico-midi-logo.svg" alt="midi-logo">
</div> </div>
@@ -18,7 +18,7 @@
<DeviceBar class="self-center" /> <DeviceBar class="self-center" />
<span <span
class="self-center text-center w-48 font-pixelsm text-xs text-muted-foreground"> class="self-center text-center w-48 font-pixelsm text-xs text-muted-foreground">
Profile description will go here! Profile description will go here! And hopefully it will be a long one! Much longer than this one! Actually, this is probably long enough. I don't think we need to make it any longer...
</span> </span>
</div> </div>
</div> </div>

View File

@@ -21,8 +21,9 @@
class="flex-1 pl-1 h-full bg-transparent focus-visible:ring-0 focus-visible:outline-none" class="flex-1 pl-1 h-full bg-transparent focus-visible:ring-0 focus-visible:outline-none"
:class="{'font-semibold bg-zinc-200 hover:bg-zinc-100 text-black' : selected, :class="{'font-semibold bg-zinc-200 hover:bg-zinc-100 text-black' : selected,
'hover:bg-zinc-900 bg-opacity-50 text-white': !selected}" 'hover:bg-zinc-900 bg-opacity-50 text-white': !selected}"
@blur="editing=false"> @blur="onNameInputBlur">
<button <button
ref="nameSubmitButton"
type="submit" type="submit"
:class="{'bg-zinc-200 hover:bg-zinc-100 text-black' : selected, :class="{'bg-zinc-200 hover:bg-zinc-100 text-black' : selected,
'hover:bg-opacity-100 bg-zinc-900 text-zinc-100 bg-opacity-50': !selected}" 'hover:bg-opacity-100 bg-zinc-900 text-zinc-100 bg-opacity-50': !selected}"
@@ -104,6 +105,8 @@ import { nextTick, ref } from 'vue'
defineEmits(['select', 'duplicate', 'delete']) defineEmits(['select', 'duplicate', 'delete'])
const nameSubmitButton = ref(null)
const profile = defineModel({ const profile = defineModel({
type: Object, type: Object,
required: true, required: true,
@@ -143,6 +146,11 @@ async function startEditing() {
profileNameInput.value.focus() profileNameInput.value.focus()
} }
function onNameInputBlur(e) {
if (e.relatedTarget === nameSubmitButton.value) return
editing.value = false
}
const profileNameInput = ref(null) const profileNameInput = ref(null)
const nameInput = ref(profile.value.name) const nameInput = ref(profile.value.name)