Skip to content

Conversation

@justinmc
Copy link
Contributor

Description

In an app with nested Navigators, selecting text in a TextField caused an exception to be logged.

This PR fixes it by removing the offending call to globalToLocal, which turns out to be unnecessary. The coordinates relative to the selection menu are always equivalent to global coordinates, because the selection menu is in an Overlay covering the entire screen. Even in situations where the containing Navigator does not cover the full screen, the Overlay still does.

Related Issues

Closes #37046

Tests

I added the following tests:

  • A test that renders an app with nested Navigators, shows the selection menu, and verifies that there were no exceptions.

@justinmc justinmc self-assigned this Sep 25, 2019
@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. labels Sep 25, 2019
final _ToolbarParentData childParentData = child.parentData;

final Offset localTopCenter = globalToLocal(Offset(_arrowTipX, _barTopY));
final Offset topCenter = Offset(_arrowTipX, _barTopY);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: localTopCenter was created so _arrowTipX and _barTopY can be converted to local coordinates. Now that it's no longer needed, removing the variable all together might make the code more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call.

@justinmc justinmc merged commit 67ea92c into flutter:master Sep 30, 2019
@justinmc justinmc deleted the cupertino-selection-exception branch September 30, 2019 16:24
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Sep 30, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception when selecting on TextField

4 participants