Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Focus on leading icon when null #164966

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

whopavan
Copy link

@whopavan whopavan commented Mar 11, 2025

Fix: Focus on leading icon when null
fixes: #164905

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

Copy link

google-cla bot commented Mar 11, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Mar 11, 2025
@dkwingsmt dkwingsmt requested a review from QuncCccccc March 12, 2025 18:22
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution. Looks like the CLA is missing. Could you follow the comment above to sign the CLA so we can move forward:)

-- UPDATE:
Just noticed the CLA has been signed! Thanks!

@@ -1099,7 +1099,7 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
child: DefaultTextStyle(style: effectiveTextStyle!, child: widget.label!),
),
),
trailingButton,
ExcludeSemantics(excluding: widget.leadingIcon == null, child: trailingButton),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we wrap trailingButton with ExcludeSemantics when leadingIcon is null?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think a better solution for this would be:

  • Implement visitChildrenForSemantics in _DropdownMenuBody.
  • All children in DropdownMenuBody are used for a measurement purpose, except the first child textField. So in the method, we can just visit the first child for its semantics and then skip the rest of them.

The method can look like this:

  @override
  void visitChildrenForSemantics(RenderObjectVisitor visitor) {
    visitChildren((RenderObject renderObjectChild) {
      final RenderBox child = renderObjectChild as RenderBox;
      if (child == firstChild) {
        visitor(renderObjectChild);
      }
      return;
    });
  }
  • Please also add a comment above this method to explain why we skip all the children except the first one. Something like: // Children except the text field (first child) are laid out for measurement purpose but not painted.

Copy link
Author

Choose a reason for hiding this comment

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

@QuncCccccc Hey, thanks for the suggestion. Have made changes accordingly, do check and let me know if I missed something. Thank you.

@whopavan whopavan force-pushed the fix-focus-on-leading-icon branch from 1f86f83 to ad1e07b Compare March 15, 2025 06:50
@whopavan whopavan force-pushed the fix-focus-on-leading-icon branch from ad1e07b to cdf25e3 Compare March 15, 2025 06:55
@dkwingsmt dkwingsmt requested a review from QuncCccccc March 19, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Accessibility] DropdownMenu - Focusable on leadingIcon when null
2 participants