fix(canvas): Save button no-op due to leaked click event

The Toolbar and Sidebar Save buttons wired onClick={onSave} directly, so
React passed the MouseEvent as the first argument. handleSave treats its
first arg as a designIdOverride, corrupting design_id and making the save
fail silently. Ctrl+S worked because it calls handleSave() with no args.

Wrap both handlers as onClick={() => onSave()} so no event leaks through.

Add regression tests asserting onSave is called with zero arguments.

Fixes #186

ha-relevant: no
This commit is contained in:
Pouzor
2026-06-05 15:22:13 +02:00
parent 754a79d21f
commit ba2f6564ec
4 changed files with 70 additions and 2 deletions
@@ -188,6 +188,15 @@ describe('Sidebar', () => {
expect(defaultProps.onSave).toHaveBeenCalledOnce()
})
// Regression (#186): the click handler must not forward the MouseEvent as an
// argument — handleSave treats its first arg as a designIdOverride, so leaking
// the event corrupts design_id and the save silently fails.
it('calls onSave with no arguments (does not leak the click event)', () => {
render(<Sidebar {...defaultProps} />)
fireEvent.click(screen.getByText('Save Canvas'))
expect(defaultProps.onSave).toHaveBeenCalledWith()
})
it('calls onOpenSettings when Settings is clicked', () => {
render(<Sidebar {...defaultProps} />)
fireEvent.click(screen.getByText('Settings'))