Skip to content

fix: read the pressed submit button from the submit event - #633

Open
Toraastrta wants to merge 1 commit into
codesnippetspro:core-betafrom
Toraastrta:fix/safari-submit-action/core
Open

Toraastrta wants to merge 1 commit into
codesnippetspro:core-betafrom
Toraastrta:fix/safari-submit-action/core

Conversation

@Toraastrta

Copy link
Copy Markdown

Fixes #606.

The editor worked out which submit button was pressed from document.activeElement. Safari, and Firefox on macOS, do not focus a button when it is clicked, so focus stays in the code editor or the title field and no action matches. Save and Activate then saves the snippet without activating it, and Save and Deactivate leaves it active.

Changes

  • SnippetForm.tsx: the submit action is read from the submit event's submitter instead of the focused element.
  • Pressing Enter in a text field such as the title still makes a plain save, as before. That kind of submit reports the form's first button as the submitter, which is Save and Deactivate when editing an active snippet.

Verification

  • New tests/e2e/editor-submit-actions.spec.ts. The clicks keep focus where it was, as Safari does, by cancelling the button's mousedown.
    • Save and Activate on a new snippet saves it active. This fails on core-beta (saved inactive).
    • Save and Deactivate on an active snippet saves it inactive. This fails on core-beta (stays active).
    • Enter in the title field of an active snippet keeps it active. This passes on core-beta and fails if the Enter check is removed from the fix.
  • The new spec, code-snippets-edit.spec.ts and editor-save-outcomes.spec.ts pass in both the chromium-db-snippets and chromium-file-based-snippets projects (28 tests).
  • ESLint passes on the changed files, and tsc --noEmit reports no errors in them.

I used Claude Code to write the fix and the tests. I reviewed the change and ran the checks above myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Save and Activate" saves but does not activate in Safari (button detected via document.activeElement)

1 participant