Change step back shortcut in command palette to Shift+Backspace (#5604)

* Change cmdbar step back shortcut to Shift+Backspace

* Add visual button for step back

* Make the shortcut apply no matter what's in the input
This commit is contained in:
Frank Noirot
2025-03-05 17:57:47 -05:00
committed by GitHub
parent c13bdbb749
commit b947dad6e9
10 changed files with 41 additions and 29 deletions

View File

@ -291,7 +291,7 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
// Review step and argument hotkeys // Review step and argument hotkeys
await expect(submitButton).toBeEnabled() await expect(submitButton).toBeEnabled()
await expect(submitButton).toBeFocused() await expect(submitButton).toBeFocused()
await submitButton.press('Backspace') await submitButton.press('Shift+Backspace')
// Assert we're back on the distance step // Assert we're back on the distance step
await expect( await expect(

View File

@ -2900,7 +2900,7 @@ extrude001 = extrude(profile001, length = 100)
await enterAppearanceFlow(`Open Set Appearance flow`) await enterAppearanceFlow(`Open Set Appearance flow`)
await test.step(`Validate hidden argument "nodeToEdit" can't be reached with Backspace`, async () => { await test.step(`Validate hidden argument "nodeToEdit" can't be reached with Backspace`, async () => {
await page.keyboard.press('Backspace') await page.keyboard.press('Shift+Backspace')
await cmdBar.expectState({ await cmdBar.expectState({
stage: 'pickCommand', stage: 'pickCommand',
}) })

View File

@ -144,7 +144,7 @@ function CommandArgOptionInput({
onKeyDown={(event) => { onKeyDown={(event) => {
if (event.metaKey && event.key === 'k') if (event.metaKey && event.key === 'k')
commandBarActor.send({ type: 'Close' }) commandBarActor.send({ type: 'Close' })
if (event.key === 'Backspace' && !event.currentTarget.value) { if (event.key === 'Backspace' && event.shiftKey) {
stepBack() stepBack()
} }

View File

@ -127,9 +127,10 @@ export const CommandBar = () => {
<CommandBarReview stepBack={stepBack} /> <CommandBarReview stepBack={stepBack} />
) )
)} )}
<div className="flex flex-col gap-2 !absolute left-auto right-full top-[-3px] m-2.5 p-0 border-none bg-transparent hover:bg-transparent">
<button <button
onClick={() => commandBarActor.send({ type: 'Close' })} onClick={() => commandBarActor.send({ type: 'Close' })}
className="group block !absolute left-auto right-full top-[-3px] m-2.5 p-0 border-none bg-transparent hover:bg-transparent" className="group m-0 p-0 border-none bg-transparent hover:bg-transparent"
> >
<CustomIcon <CustomIcon
name="close" name="close"
@ -140,6 +141,21 @@ export const CommandBar = () => {
<kbd className="hotkey ml-4 dark:!bg-chalkboard-80">esc</kbd> <kbd className="hotkey ml-4 dark:!bg-chalkboard-80">esc</kbd>
</Tooltip> </Tooltip>
</button> </button>
{!commandBarState.matches('Selecting command') && (
<button onClick={stepBack} className="m-0 p-0 border-none">
<CustomIcon name="arrowLeft" className="w-5 h-5 rounded-sm" />
<Tooltip position="bottom" delay={500}>
Step back{' '}
<kbd className="hotkey ml-4 dark:!bg-chalkboard-80">
Shift
</kbd>
<kbd className="hotkey ml-4 dark:!bg-chalkboard-80">
Bksp
</kbd>
</Tooltip>
</button>
)}
</div>
</WrapperComponent.Panel> </WrapperComponent.Panel>
</Transition.Child> </Transition.Child>
</WrapperComponent> </WrapperComponent>

View File

@ -55,7 +55,7 @@ function CommandBarBasicInput({
| undefined) || (arg.defaultValue as string) | undefined) || (arg.defaultValue as string)
} }
onKeyDown={(event) => { onKeyDown={(event) => {
if (event.key === 'Backspace' && !event.currentTarget.value) { if (event.key === 'Backspace' && event.shiftKey) {
stepBack() stepBack()
} }
}} }}

View File

@ -146,14 +146,10 @@ function CommandBarKclInput({
}, },
}, },
{ {
key: 'Backspace', key: 'Shift-Backspace',
run: (editor) => { run: () => {
// Only step back if the editor is empty
if (editor.state.doc.toString() === '') {
stepBack() stepBack()
return true return true
}
return false
}, },
}, },
]), ]),

View File

@ -8,7 +8,7 @@ function CommandBarReview({ stepBack }: { stepBack: () => void }) {
context: { argumentsToSubmit, selectedCommand }, context: { argumentsToSubmit, selectedCommand },
} = commandBarState } = commandBarState
useHotkeys('backspace', stepBack, { useHotkeys('backspace+shift', stepBack, {
enableOnFormTags: true, enableOnFormTags: true,
enableOnContentEditable: true, enableOnContentEditable: true,
}) })

View File

@ -142,7 +142,7 @@ function CommandBarSelectionInput({
placeholder="Select an entity with your mouse" placeholder="Select an entity with your mouse"
className="absolute inset-0 w-full h-full opacity-0 cursor-default" className="absolute inset-0 w-full h-full opacity-0 cursor-default"
onKeyDown={(event) => { onKeyDown={(event) => {
if (event.key === 'Backspace') { if (event.key === 'Backspace' && event.shiftKey) {
stepBack() stepBack()
} else if (event.key === 'Escape') { } else if (event.key === 'Escape') {
commandBarActor.send({ type: 'Close' }) commandBarActor.send({ type: 'Close' })

View File

@ -120,7 +120,7 @@ export default function CommandBarSelectionMixedInput({
placeholder="Select an entity with your mouse" placeholder="Select an entity with your mouse"
className="absolute inset-0 w-full h-full opacity-0 cursor-default" className="absolute inset-0 w-full h-full opacity-0 cursor-default"
onKeyDown={(event) => { onKeyDown={(event) => {
if (event.key === 'Backspace') { if (event.key === 'Backspace' && event.shiftKey) {
stepBack() stepBack()
} else if (event.key === 'Escape') { } else if (event.key === 'Escape') {
commandBarActor.send({ type: 'Close' }) commandBarActor.send({ type: 'Close' })

View File

@ -56,7 +56,7 @@ function CommandBarTextareaInput({
| undefined) || (arg.defaultValue as string) | undefined) || (arg.defaultValue as string)
} }
onKeyDown={(event) => { onKeyDown={(event) => {
if (event.key === 'Backspace' && !event.currentTarget.value) { if (event.key === 'Backspace' && event.shiftKey) {
stepBack() stepBack()
} else if ( } else if (
event.key === 'Enter' && event.key === 'Enter' &&