-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#44806Labels
a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamOwned by Web platform team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Run the sample app on web
- Press SHIFT, then press the arrow left key 8 times
Expected results
We should receive the following selection, as we are expanding the selection upstream:
TextSelection(
baseOffset: 57,
extentOffset: 49,
)Actual results
We receive the following selection:
TextSelection(
baseOffset: 49,
extentOffset: 57,
)Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({
super.key,
});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with DeltaTextInputClient {
TextInputConnection? _imeConnection;
TextEditingValue _currentTextEditingValue = const TextEditingValue(
text: 'Press SHIFT + Left arrow to expand the selection upstream',
selection: TextSelection.collapsed(offset: 57),
);
@override
void initState() {
super.initState();
_attachToIme();
}
@override
void dispose() {
_detachFromIme();
super.dispose();
}
@override
void updateEditingValueWithDeltas(List<TextEditingDelta> textEditingDeltas) {
TextEditingValue newValue = _currentTextEditingValue.copyWith();
for (final delta in textEditingDeltas) {
print('Applying delta: $delta');
newValue = delta.apply(newValue);
}
print('New editing value: $newValue');
setState(() {
_currentTextEditingValue = newValue;
});
}
void _attachToIme() {
if (_imeConnection != null && _imeConnection!.attached) {
return;
}
const config = TextInputConfiguration(
enableDeltaModel: true,
inputType: TextInputType.multiline,
inputAction: TextInputAction.newline,
);
_imeConnection = TextInput.attach(this, config);
_imeConnection!.setEditingState(_currentTextEditingValue);
_imeConnection!.show();
}
void _detachFromIme() {
_imeConnection?.close();
_imeConnection = null;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Focus(
autofocus: true,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Text: ${_currentTextEditingValue.text}'),
const SizedBox(height: 30),
Text('Selection: ${_currentTextEditingValue.selection}'),
const SizedBox(height: 30),
Text('Selected text: ${_currentTextEditingValue.selection.textInside(_currentTextEditingValue.text)}'),
],
),
),
),
);
}
@override
void connectionClosed() {}
@override
AutofillScope? get currentAutofillScope => null;
@override
TextEditingValue? get currentTextEditingValue => _currentTextEditingValue;
@override
void didChangeInputControl(TextInputControl? oldControl, TextInputControl? newControl) {}
@override
void insertContent(KeyboardInsertedContent content) {}
@override
void insertTextPlaceholder(Size size) {}
@override
void performAction(TextInputAction action) {}
@override
void performPrivateCommand(String action, Map<String, dynamic> data) {}
@override
void performSelector(String selectorName) {}
@override
void removeTextPlaceholder() {}
@override
void showAutocorrectionPromptRect(int start, int end) {}
@override
void showToolbar() {}
@override
void updateEditingValue(TextEditingValue value) {}
@override
void updateFloatingCursor(RawFloatingCursorPoint point) {}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
No relevant logs.Flutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.13.0-11.0.pre.18, on Microsoft Windows [versÆo 10.0.22000.2176], locale pt-BR)
• Flutter version 3.13.0-11.0.pre.18 on channel master at c:\git\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f8afcd5aa0 (7 days ago), 2023-07-27 19:34:03 -0400
• Engine revision 196474bd96
• Dart version 3.2.0 (build 3.2.0-8.0.dev)
• DevTools version 2.25.0
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\angelo\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.5.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.5.33516.290
• Windows 10 SDK version 10.0.22621.0
[✓] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[✓] VS Code (version 1.80.2)
• VS Code at C:\Users\angelo\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.70.0
[✓] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [versÆo 10.0.22000.2176]
• Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.111
• Edge (web) • edge • web-javascript • Microsoft Edge 115.0.1901.188
[✓] Network resources
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamOwned by Web platform team