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
await expect(submitButton).toBeEnabled()
await expect(submitButton).toBeFocused()
await submitButton.press('Backspace')
await submitButton.press('Shift+Backspace')
// Assert we're back on the distance step
await expect(

View File

@ -2900,7 +2900,7 @@ extrude001 = extrude(profile001, length = 100)
await enterAppearanceFlow(`Open Set Appearance flow`)
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({
stage: 'pickCommand',
})

View File

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

View File

@ -127,9 +127,10 @@ export const CommandBar = () => {
<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
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
name="close"
@ -140,6 +141,21 @@ export const CommandBar = () => {
<kbd className="hotkey ml-4 dark:!bg-chalkboard-80">esc</kbd>
</Tooltip>
</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>
</Transition.Child>
</WrapperComponent>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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