Skip to content

refactor: improve overlay select and tabs#50

Closed
leoafarias wants to merge 9 commits intomainfrom
leoafarias/refactor-overlay-select
Closed

refactor: improve overlay select and tabs#50
leoafarias wants to merge 9 commits intomainfrom
leoafarias/refactor-overlay-select

Conversation

@leoafarias
Copy link
Copy Markdown
Contributor

Description

Refactors overlay-based select and tabs widgets for improved code clarity and performance. Inlines the overlay state mixin and improves documentation for focus management behavior. Also optimizes focus iteration in tabs to avoid redundant method calls.

Related Issues

Improves code maintainability and performance of NakedSelect and NakedTabs widgets.


Checklist

  • My PR includes unit or integration tests for all changed/updated/fixed behaviors.
  • I have updated or added relevant documentation (doc comments with ///).
  • I am prepared to follow up on review comments in a timely manner.

Breaking Change

  • No, this is not a breaking change.

Remove OverlayStateMixin and inline session tracking directly into
NakedMenu and NakedSelect for simpler, self-contained state management.
Add configurable pageJumpSize to NakedSelect and extract NakedTextField
build method into smaller focused helpers.
@docs-page
Copy link
Copy Markdown

docs-page Bot commented Feb 19, 2026

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/naked_ui~50

Documentation is deployed and generated using docs.page.

Rename _defaultPageJumpFallback to _maxPageJumpSize for clarity.
Simplify textfield helper methods by accessing _effectiveController
and _effectiveFocusNode directly instead of threading them as params.
@leoafarias leoafarias requested a review from Copilot February 19, 2026 23:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors overlay-based widgets (NakedSelect, NakedMenu, and NakedTabs) and NakedTextField to improve code organization and performance. The refactoring inlines the OverlayStateMixin directly into the widgets that use it, adds a configurable pageJumpSize parameter to NakedSelect for PageUp/PageDown navigation, and optimizes focus iteration in NakedTabs by using dynamic bounds based on actual traversal descendant counts. The NakedTextField refactoring extracts the large build method into smaller, more maintainable helper methods without changing functionality.

Changes:

  • Refactored NakedTextField's build method into smaller helper methods for better code organization
  • Inlined OverlayStateMixin into NakedSelect and NakedMenu states, removing the shared mixin
  • Added configurable pageJumpSize parameter to NakedSelect for customizable PageUp/PageDown navigation
  • Optimized focus iteration in NakedTabs by calculating dynamic iteration limits based on traversal descendants

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/naked_ui/lib/src/naked_textfield.dart Refactored large build method into focused helper methods (_buildInputFormatters, _buildEditableText, _wrapEditable, _handleSemanticTap, _wrapSemantics, _buildContent, _wrapFocusSemantics, _wrapSelectionGestureDetector, _wrapMouseRegion) for improved maintainability
packages/naked_ui/lib/src/naked_tabs.dart Changed from static iteration limit (100) to dynamic limit based on traversalDescendants.length for more accurate focus traversal bounds
packages/naked_ui/lib/src/naked_select.dart Inlined OverlayStateMixin functionality, added pageJumpSize parameter with validation, implemented _pageJumpSizeForScope method to calculate dynamic jump sizes, and updated documentation
packages/naked_ui/lib/src/naked_menu.dart Inlined OverlayStateMixin functionality, directly implementing selection tracking and focus management logic
packages/naked_ui/lib/src/base/overlay_base.dart Removed OverlayStateMixin as it's now inlined into the widgets that used it

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The parity tests hardcoded SystemMouseCursors.click for Material
enabled widgets. Flutter 3.41.2 changed the default cursor, breaking
CI. Now the tests query Material's actual cursor and assert Naked
matches it, which is the correct parity behavior.
@github-actions
Copy link
Copy Markdown
Contributor

LCOV of commit f0634e7 during Flutter CI #167

	(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.......: 89.1% (1890 of 2122 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/base/overlay_base.dart                 |79.2%     24|    -     0|    -      0
  packages/naked_ui/lib/src/naked_menu.dart                        |79.4%     97|    -     0|    -      0
  packages/naked_ui/lib/src/naked_select.dart                      |86.9%    153|    -     0|    -      0
  packages/naked_ui/lib/src/naked_tabs.dart                        |91.1%    169|    -     0|    -      0
  packages/naked_ui/lib/src/naked_textfield.dart                   |86.7%    353|    -     0|    -      0

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +277 to +282
/// Number of items to jump for PageUp/PageDown.
///
/// When null, the jump size is derived from the number of traversal
/// descendants in the overlay's focus scope, capped to a reasonable
/// upper bound.
final int? pageJumpSize;
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The new pageJumpSize parameter lacks test coverage. While the default behavior (using traversalDescendants.length) is tested indirectly through existing PageUp/PageDown tests, there are no tests verifying that a custom pageJumpSize value is respected. Consider adding a test that sets an explicit pageJumpSize (e.g., 5) and verifies that PageUp/PageDown move focus by exactly that amount.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

LCOV of commit 262ccb9 during Flutter CI #168

	(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.......: 89.1% (1890 of 2122 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/base/overlay_base.dart                 |79.2%     24|    -     0|    -      0
  packages/naked_ui/lib/src/naked_menu.dart                        |79.4%     97|    -     0|    -      0
  packages/naked_ui/lib/src/naked_select.dart                      |86.9%    153|    -     0|    -      0
  packages/naked_ui/lib/src/naked_tabs.dart                        |91.1%    169|    -     0|    -      0
  packages/naked_ui/lib/src/naked_textfield.dart                   |86.7%    353|    -     0|    -      0

@leoafarias leoafarias closed this Feb 20, 2026
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