-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Use SystemContextMenu by default on iOS #165354
base: master
Are you sure you want to change the base?
Conversation
For EditableText, but not for SelectionArea.
…endered menu Any problem with accessing an InheritedWidget here?
Slight hack in here to make sure MediaQuery gets the updated isSupported value.
), | ||
) | ||
as WidgetsBindingObserver; | ||
widgetsBindingObserver.didChangeMetrics(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone know of a better way to do this? MediaQuery.fromView gets its values set from the view once per run of flutter test
. When I change isSupported on the view, MediaQuery does not reflect the updated value unless I call something like didChangeMetrics on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Renzo-Olivares had an idea to insert another MediaQuery into the tree and set its value of supportsShowingSystemContextMenu. I tried it and it didn't seem to work. SystemContextMenu is built in contextMenuBuilder, and the BuildContext it gets is from its OverlayEntry, which is near the root of the tree. So unfortunately when it looks up the nearest MediaQuery, it misses the one that I put in the tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing to try from @Renzo-Olivares was changing the AppLifecycleState to get the view to rebuild. This succeeded in getting _MediaQueryFromView.didUpdateWidget to be called, but the logic in that method does not update the view data unless the entire view changes.
I suspect that might be a bug, so I opened an issue: #165519.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider making this method private if we intend to change it, but I also think its fine as is since its in the framework tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it private, I think that's probably a good call despite the duplication. Hopefully we can fix the bug and then remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo analyzer errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for writing so many tests!
With this change, widgets based on EditableText will show the system context menu by default on iOS. Anyone with a custom contextMenuBuilder will not be affected and will have to opt-in to using SystemContextMenu. Also, this does not affect SelectionArea, which can't receive paste.
Fixes #163067