Skip to content

Update transformHitTests documentation for clarity #174286

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

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

Conversation

Rushikeshbhavsar20
Copy link
Contributor

@Rushikeshbhavsar20 Rushikeshbhavsar20 commented Aug 22, 2025

Description 📝

This PR updates the documentation for the transformHitTests parameter in the Transform widget to resolve ambiguity in the API documentation that has caused hit testing issues for developers.

The current documentation simply states "Whether to apply the transformation when performing hit tests" which is ambiguous. As seen in issues like #27587, developers expect transformed widgets to receive touch events across their entire visual area, but hits only register within the parent's original bounds.

The core issue: The documentation lacks clarity on:
❌ Hit test coordinate system transformation vs. hit test bounds expansion
🔄 Parent widget bounds as the constraint for hit test registration
⚠️ The distinction between visual rendering bounds and interactive bounds

Before (Current Documentation)

Current documentation is vague: "Whether to apply the transformation when performing hit tests"

Screenshot 2025-08-22 214745

After (Improved Documentation)

Screenshot 2025-08-22 214808

New documentation clearly explains behavior, limitations, and solutions

Changes made:

  • 🔧 Clarified that transformHitTests transforms registered hits into the child's resulting coordinate system
  • 🚨 Explicitly documented the critical limitation: only hits within parent bounds can be registered
  • 📚 Explained the behavior difference between true and false settings with concrete examples of transformation types
  • 💡 Added guidance for common workarounds: expanding parent bounds or using Overlay for out-of-bounds elements

Issues Fixed 🐛

Fixes #78120

Related issues that motivated this change: 🔗

Note: This PR is test-exempt as it only updates documentation comments without changing any functionality.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Fixes flutter#78120

- Clarified that only hits within parent bounds can be registered
- Explained coordinate transformation behavior for both true/false cases
- Added guidance for handling out-of-bounds interactive elements
- Referenced Overlay as alternative solution
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 22, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the documentation for the transformHitTests property on the Transform widget. The new documentation is much clearer and addresses a common point of confusion for developers by explicitly stating the limitations of hit testing with transforms. The other changes in this PR are minor formatting adjustments. My review includes a suggestion to further enhance the documentation by adding a code example, as recommended by the style guide.

- Removed outdated explanation of hit test behavior.
- Added detailed description of coordinate transformation rules.
- Included runnable code snippet demonstrating scaling and tap region limits.

Fixes flutter#78120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transforms transformHitTests description is not clear enough
1 participant