Fix argument persistence and accidental submission command bar bugs (#3021)

This commit is contained in:
Frank Noirot
2024-07-14 18:15:34 -04:00
committed by GitHub
parent 29bf77bb82
commit 1852e6167b
5 changed files with 73 additions and 36 deletions

View File

@ -203,7 +203,7 @@ export const commandBarMachine = createMachine(
'Change current argument': {
target: 'Gathering arguments',
internal: true,
actions: ['Remove current argument and set a new one'],
actions: ['Set current argument'],
},
'Deselect command': {
@ -359,29 +359,13 @@ export const commandBarMachine = createMachine(
switch (event.type) {
case 'Edit argument':
return event.data.arg
case 'Change current argument':
return Object.values(event.data)[0]
default:
return context.currentArgument
}
},
}),
'Remove current argument and set a new one': assign({
argumentsToSubmit: (context, event) => {
if (
event.type !== 'Change current argument' ||
!context.currentArgument
)
return context.argumentsToSubmit
const { name } = context.currentArgument
const { [name]: _, ...rest } = context.argumentsToSubmit
return rest
},
currentArgument: (context, event) => {
if (event.type !== 'Change current argument')
return context.currentArgument
return Object.values(event.data)[0]
},
}),
'Clear argument data': assign({
selectedCommand: undefined,
currentArgument: undefined,