| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
merge dev into dev pick !123929 !134870 Created-by: AndCJ Commit-by: tauu;luckysmg Merged-by: ohci1 Description: https://github.com/flutter/flutter/pull/123929/commits https://github.com/flutter/flutter/pull/134870/commits See merge request: openharmony-sig/flutter_flutter!489 | 1 年前 | |
[web] fix: do not call onSubmitted of TextField when switching browser tabs on mobile web (#134870) This PR fixes #134846. As discussed in the issue, the onSubmitted callback of a TextField is called when the browser switches tabs or is sent to the background if the flutter app is running in any mobile browser (desktop browsers are not affected). Furthermore there is no straight forward way to distinguish between onSubmitted being called because the user pressed the enter key and it being called because the user switched tabs. For example in a chat app this would cause a message to be sent when the user submits the text by pressing "send" on the virtual keyboard as well as when the user switches to another tab. The later action is likely not so much intended. The next section explains what causes the bug and explains the proposed fix. The root cause for this behaviour is line 3494 in editable_text.dart: https://github.com/flutter/flutter/blob/0b540a87f1be9a5bb7e550c777dfe5221c53a112/packages/flutter/lib/src/widgets/editable_text.dart#L3487-L3499 Only if the app is running on the web _finalizeEditing is called and this will then trigger the onSubmitted callback. If flutter is running on the web, there are only exactly 3 cases, in which the function is called. The following call trace analysis will describe why. - connectionClosed() is only called by in one location, _handleTextInputInvocation of the TextInput service. https://github.com/flutter/flutter/blob/367203b3011fc1752cfa1f51adf9751d090c94e6/packages/flutter/lib/src/services/text_input.dart#L1896C12-L1899 - In particular it is only called if the TextInput service receives a 'TextInputClient.onConnectionClosed' message from the engine. - The only location where the web part of the engine send this message is the onConnectionClosed function of the TextEditingChannel. https://github.com/flutter/engine/blob/cbda68a720904137ee9dfdf840db323afcf52705/lib/web_ui/lib/src/engine/text_editing/text_editing.dart#L2242-L2254 - onConnectionClosed in turn is only called by the sendTextConnectionClosedToFrameworkIfAny function of HybridTextEditing. https://github.com/flutter/engine/blob/cbda68a720904137ee9dfdf840db323afcf52705/lib/web_ui/lib/src/engine/text_editing/text_editing.dart#L2340-L2345 The function sendTextConnectionClosedToFrameworkIfAny is only called at 3 distinct locations of the web engine. As described in the comment sendTextConnectionClosedToFrameworkIfAny is called if the browser is sent to the background or the tab is changed. https://github.com/flutter/engine/blob/cbda68a720904137ee9dfdf840db323afcf52705/lib/web_ui/lib/src/engine/text_editing/text_editing.dart#L1632-L1656 Same situation as for iOS. sendTextConnectionClosedToFrameworkIfAny is also called if windowHasFocus is false, which is the case if the browser is sent to background or the tab is changed. https://github.com/flutter/engine/blob/cbda68a720904137ee9dfdf840db323afcf52705/lib/web_ui/lib/src/engine/text_editing/text_editing.dart#L1773-L1785 This call seems to always happen when finishAutofillContext is triggered by the framework. https://github.com/flutter/engine/blob/cbda68a720904137ee9dfdf840db323afcf52705/lib/web_ui/lib/src/engine/text_editing/text_editing.dart#L2075-L2083 The fixed proposed and implemented by this PR is to simply delete the call to_finalizeEditing in the connectionClosed function of editable_text.dart. https://github.com/flutter/flutter/blob/0b540a87f1be9a5bb7e550c777dfe5221c53a112/packages/flutter/lib/src/widgets/editable_text.dart#L3487-L3499 The reasoning for this being: * _finalizeEditing is only called in connectionClosed for the web engine. * As explained by the trace analysis above, the web engine only triggers this _finalizeEditing call in 3 cases. * In the 2 cases for IOSTextEditingStrategy and AndroidTextEditingStrategy the web engine triggering the call only causes the undesired behaviour reported in the issue. * In the third case for TextInputFinishAutofillContext, I can't see a good reason why this would require calling _finalizeEditing as it only instructs the platform to save the current values. Other platforms also don't have anything that would trigger onSubmitted being called, so it seems safe to remove it. * For other platforms the onConnectionClosed function was recently incorporated to only unfocus the TextField. So removing the call _finalizeEditing unifies the platform behaviour. See also https://github.com/flutter/flutter/pull/123929 https://github.com/flutter/engine/pull/41500 *List which issues are fixed by this PR. You must list at least one issue.* To simplify the evaluation, here are two versions of the minimal example given in the issue, build with the current master and with this PR applied: current master: https://tauu.github.io/flutter-onsubmit-test/build/web-master/ current master + PR applied: https://tauu.github.io/flutter-onsubmit-test/build/web/ | 1 年前 | |
Refactor fix_data.yaml (#114192) * Refactor fix_data.yaml * ++ * lib, not lib/src * Nit * Nit * Update packages/flutter/test_fixes/material/app_bar_theme.dart Co-authored-by: Alexander Dahlberg <dustbin4ever@gmail.com> * Fix copy paste errors Co-authored-by: Alexander Dahlberg <dustbin4ever@gmail.com> | 3 年前 | |
[flutter_tools] Pin package:archive and manual roll (#115662) * add package:archive to pins * roll | 3 年前 | |
[framework] dont null assert in _debugVerifyIllFatedPopulation (#96551) | 4 年前 | |
Instrument State, Layer, RenderObject and Element. (#111328) | 3 年前 | |
Add LICENSE file to packages/flutter, add test to make sure it… (#53799) This adds a LICENSE file to the packages/flutter directory so that it can be found when building, and a test to make sure it exists in produced binaries. | 6 年前 | |
[flutter] Update package README (#70968) | 5 年前 | |
Clean-up analysis_options files (#77098) | 5 年前 | |
skip web test on crazy import (#34017) | 6 年前 | |
Add tag support for executing reduced test sets (#86821) | 4 年前 | |
[flutter_tools] Pin package:archive and manual roll (#115662) * add package:archive to pins * roll | 3 年前 | |
上传单元测试的测试结果 Signed-off-by: lwtt <1377477209@qq.com> | 2 年前 |
Flutter
Flutter is a new way to build high-performance, cross-platform mobile, web, and desktop apps. Flutter is optimized for today's — and tomorrow's — mobile and desktop devices. We are focused on low-latency input and high frame rates on all platforms.
See the getting started guide for information about using Flutter.