Skip to content

fix(naked-ui): correct selection semantics and press state - #84

Merged
leoafarias merged 2 commits into
mainfrom
fix/selection-semantics-press-state
Aug 4, 2026
Merged

fix(naked-ui): correct selection semantics and press state#84
leoafarias merged 2 commits into
mainfrom
fix/selection-semantics-press-state

Conversation

@leoafarias

@leoafarias leoafarias commented Aug 4, 2026

Copy link
Copy Markdown
Member

Description

Corrects two shared interaction contracts used by Remix components.

NakedToggleOption now marks options as members of a mutually exclusive group, matching Flutter's segmented-control semantics while preserving explicit child nodes, controlled selection, and disabled behavior.

NakedTextField now keeps its public press callbacks and WidgetState.pressed synchronized when multi-tap selection, drag selection, scrolling, or force press takes ownership. Disabled tap, drag, directional-navigation, and force-press paths are gated before Flutter's selection behavior runs.

Adversarial review exposed one lifecycle edge case in that implementation: Flutter's tap tracker also resets when its recognizer is disposed. Forwarding that reset synchronously could invoke a consumer callback that rebuilt an ancestor while the widget tree was locked. The reset now clears internal pressed state immediately, defers consumer callbacks until rebuilding is safe, skips them after unmount, and invalidates stale deferred resets when a newer press transition wins.

This is a behavioral and accessibility correction with no public API or rendered design change, so screenshots are not applicable.

Validation

  • Regression test reproduced setState() or markNeedsBuild() called when widget tree was locked on the prior implementation and passes with the lifecycle-safe reset.
  • flutter test test/src/naked_textfield_press_state_test.dart test/src/naked_textfield_test.dart test/semantics/naked_textfield_semantics_test.dart test/src/naked_toggle_test.dart test/semantics/naked_toggle_semantics_test.dart — 109 passed.
  • flutter test — 678 passed, 3 intentionally skipped external integration tests.
  • flutter analyze --fatal-infos — no issues.
  • dart format --output=none --set-exit-if-changed ... — 0 changed.
  • git diff --check — clean.
  • Final adversarial review — no remaining findings.

Related Issues

No linked issue was supplied.


Checklist

  • My PR includes unit or integration tests for all changed/updated/fixed behaviors.
  • Existing public doc comments remain accurate; no API documentation change is required.
  • I am prepared to follow up on review comments in a timely manner.

Breaking Change

Does this PR require users of the package to manually update their code?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

LCOV of commit bfa0b68 during Flutter CI #274

	(use "lcov --ignore-errors deprecated,deprecated ..." to suppress this warning)
Reading tracefile /tmp/__zgosalvez_github-actions-report-lcov/lcov.info.
Summary coverage rate:
  source files: 22
  lines.......: 90.0% (2990 of 3323 lines)
  functions...: no data found
  branches....: no data found
Message summary:
  1 warning message:
    deprecated: 1

Files changed coverage rate:
  	(use "lcov --ignore-errors deprecated,deprecated ..." to suppress this warning)
                                                                   |Lines       |Functions  |Branches    
  Filename                                                         |Rate     Num|Rate    Num|Rate     Num
  packages/naked_ui/lib/src/naked_textfield.dart                   |89.6%    383|    -     0|    -      0
  packages/naked_ui/lib/src/naked_toggle.dart                      |94.4%    480|    -     0|    -      0

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

LCOV of commit 39055a4 during Flutter CI #275

	(use "lcov --ignore-errors deprecated,deprecated ..." to suppress this warning)
Reading tracefile /tmp/__zgosalvez_github-actions-report-lcov/lcov.info.
Summary coverage rate:
  source files: 22
  lines.......: 90.0% (3002 of 3335 lines)
  functions...: no data found
  branches....: no data found
Message summary:
  1 warning message:
    deprecated: 1

Files changed coverage rate:
  	(use "lcov --ignore-errors deprecated,deprecated ..." to suppress this warning)
                                                                   |Lines       |Functions  |Branches    
  Filename                                                         |Rate     Num|Rate    Num|Rate     Num
  packages/naked_ui/lib/src/naked_textfield.dart                   |89.9%    395|    -     0|    -      0
  packages/naked_ui/lib/src/naked_toggle.dart                      |94.4%    480|    -     0|    -      0

@tilucasoli tilucasoli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@leoafarias
leoafarias merged commit f58c052 into main Aug 4, 2026
8 checks passed
@leoafarias
leoafarias deleted the fix/selection-semantics-press-state branch August 4, 2026 21:09
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.

2 participants