Skip to content

fix(fuselage-forms): unsubscribe detached label actions - #2262

Open
YashAnand69 wants to merge 1 commit into
RocketChat:mainfrom
YashAnand69:fix/form-label-action-cleanup
Open

YashAnand69 wants to merge 1 commit into
RocketChat:mainfrom
YashAnand69:fix/form-label-action-cleanup

Conversation

@YashAnand69

Copy link
Copy Markdown

Proposed changes (including videos or screenshots)

Unsubscribe wrapped-input label actions when the input ref detaches.

FieldProvider already returns an unsubscribe function, but the context type hides that return value and useFieldWrappedByInputLabel discards it. Return it to useSafeRefCallback so StrictMode ref replay does not register duplicate clicks and replacing an input releases the detached node.

Issue(s)

Closes #2261

Further comments

  • Before the fix: clicking a checkbox label in StrictMode toggles twice; replacing an input leaves its old click handler active. Both DOM regressions fail.
  • Full forms suite passes: 3 suites, 44 tests, 14 snapshots. Package lint, TypeScript, formatting and diff checks pass.
  • Context onAction now explicitly returns its existing unsubscribe function; the default context supplies a no-op cleanup. Custom providers will need to follow this return contract.
  • Patch changeset included. No visual styles/markup changed; no visual regression run.

AI assistance: implemented and tested with OpenAI Codex.

@changeset-bot

changeset-bot Bot commented Sep 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8ea2795

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@rocket.chat/fuselage-forms Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

fuselage-forms: wrapped input label actions survive ref cleanup

1 participant