Skip to content

Commit a20fb7d

Browse files
authored
Allow unsetting widget labels (#6773)
https://github.com/user-attachments/assets/af344318-dac2-4611-b080-910cdfa1e87d Quick followup to #6752 - Adds support for placeholder values in dialogService.prompt - When label is unset, initial prompt is empty - Display original widget name as placeholder - When prompt returns an empty string (as opposed to null for a canceled operation), remove widget label ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6773-Allow-unsetting-widget-labels-2b16d73d365081ae9f5dd085d0081733) by [Unito](https://www.unito.io)
1 parent 836cd7f commit a20fb7d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/components/dialog/content/PromptDialogContent.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<InputText
55
ref="inputRef"
66
v-model="inputValue"
7+
:placeholder
78
autofocus
89
@keyup.enter="onConfirm"
910
@focus="selectAllText"
@@ -28,6 +29,7 @@ const props = defineProps<{
2829
message: string
2930
defaultValue: string
3031
onConfirm: (value: string) => void
32+
placeholder?: string
3133
}>()
3234
3335
const inputValue = ref<string>(props.defaultValue)

src/services/dialogService.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,13 @@ export const useDialogService = () => {
304304
async function prompt({
305305
title,
306306
message,
307-
defaultValue = ''
307+
defaultValue = '',
308+
placeholder
308309
}: {
309310
title: string
310311
message: string
311312
defaultValue?: string
313+
placeholder?: string
312314
}): Promise<string | null> {
313315
return new Promise((resolve) => {
314316
dialogStore.showDialog({
@@ -320,7 +322,8 @@ export const useDialogService = () => {
320322
defaultValue,
321323
onConfirm: (value: string) => {
322324
resolve(value)
323-
}
325+
},
326+
placeholder
324327
},
325328
dialogComponentProps: {
326329
onClose: () => {

src/services/litegraphService.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,11 +836,12 @@ export const useLitegraphService = () => {
836836
const newLabel = await useDialogService().prompt({
837837
title: t('g.rename'),
838838
message: t('g.enterNewName') + ':',
839-
defaultValue: overWidget.label ?? overWidget.name
839+
defaultValue: overWidget.label,
840+
placeholder: overWidget.name
840841
})
841-
if (!newLabel) return
842-
overWidget.label = newLabel
843-
input.label = newLabel
842+
if (newLabel === null) return
843+
overWidget.label = newLabel || undefined
844+
input.label = newLabel || undefined
844845
useCanvasStore().canvas?.setDirty(true)
845846
}
846847
})

0 commit comments

Comments
 (0)