Repository navigation
Conversation
ashalugin
left a comment
There was a problem hiding this comment.
Tested this revision with Node 26.13.1 and npm 11.21.2. The full static gate, module suite, and component suites on React 18 and 19 passed. Additional checks reproduced the issues in the inline comments.
| const GlobalHotkeys = ({children}: {children: ReactNode}) => { | ||
| const builderStore = useBuilderStore() | ||
| const handleKeyDown = useHotkeys() | ||
| const hotkeysDisabled = builderStore.props.hotkeys === false |
There was a problem hiding this comment.
Apply hotkey changes after mount
Mount with default hotkeys, then rerender the same FormBuilder with hotkeys={false}. With focus on the page body, the designer still prevents both Ctrl/Cmd+S and Ctrl/Cmd+P and calls window.print(). Starting with false and rerendering with bindings: {print: {key: 'F8'}} leaves F8 inactive. The store keeps its initial props for the lifetime of the component. Read the current hotkeys prop for listener registration and binding resolution so a host can take over without remounting the designer.
| if (binding === false || binding === undefined) continue | ||
| const list = Array.isArray(binding) ? binding : [binding] | ||
| for (const hotkey of list) { | ||
| result.push([hotkey, action]) |
There was a problem hiding this comment.
Handle conflicting chords before dispatch
Set bindings: {print: {key: 'Delete'}}, select a field, and dispatch a Delete keydown with focus on the page body. The selected field is removed and Print never runs. The default Delete binding appears before the override, and the handler uses the first match. Please detect conflicting chords or define explicit precedence so a configured Print shortcut cannot silently delete a field.
| hotkeys={{ | ||
| bindings: { | ||
| // Replace only Save’s default Ctrl/Cmd+S chord; Delete, duplicate, print, undo, redo stay default | ||
| save: {key: 's', alt: true}, |
There was a problem hiding this comment.
Use a Save example that works on macOS
On the macOS US layout, Option+S produces ß (U+00DF). I verified the native keyboard translation and confirmed that dispatching a keydown with key: 'ß' and altKey: true leaves Save untouched. A non-character chord such as F8 avoids the layout-dependent character in this example. KeyboardEvent.key values
BuilderStore keeps mount-time props, so toggling hotkeys after mount had no effect. Provide the live hotkeys prop through React context for listener registration and binding resolution.
When Print was bound to Delete, the default Delete binding still matched first and removed the selection. Drop conflicting default chords and prefer overrides in the resolved list.
Hard-coded Ctrl/Cmd+P stayed visible when print was disabled or remapped. Show the resolved print chord, or omit the hint when there is none.
Option+S is layout-dependent on macOS US (produces ß), so the example could not trigger Save. Prefer a non-character chord.
…gner-hotkey-disable-remapping-and-imperative-actions
Assert Preview/Edit mode after deferred print flush so disabled-hotkey checks cannot false-pass, cover live remap and Ctrl/Cmd+S, prove Delete override keeps the selection, and guard formatHotkeyShortcut navigator.
React 18 treated the license/SearchForm updates from that pattern as console errors under vitest-fail-on-console.
|
Tested The Print shortcut can delete a field. Use the following binding order. hotkeys={{bindings: {deleteSelected: {key: 'F8'}, print: {key: 'F8'}}}}The Print menu displays F8. Select a field, move focus to the page body, and press F8. The field is deleted and TypeScript compatibility. Existing custom implementations and mocks of
|
|
Fixed in 146eeb1 duplicate chord conflicts (e.g. |
…gner-hotkey-disable-remapping-and-imperative-actions
Summary
FormBuilderProps.hotkeysto disable all designer global shortcuts or remap/disable individual actions for embedding hosts.IFormBuilderwith imperativedeleteSelected,cloneSelected,save,print,undo, andredoso hosts can register external hotkeys.features/printand document embedding usage.Packages affected
@react-form-builder/designerChecklist
npm run check-alllocally (or explain why not)tests/when appropriatedocumentation/docsfor user-facing changesBreaking changes / migration
None.