Skip to content
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

Impossible to type a space on the web #14

Open
sarbogast opened this issue May 14, 2023 · 3 comments
Open

Impossible to type a space on the web #14

sarbogast opened this issue May 14, 2023 · 3 comments

Comments

@sarbogast
Copy link
Contributor

Describe the bug
When I use a ChipsInput field on the web, and I try to type a space in the text field, it is completely ignored. Yet, it works on iOS for example.

To Reproduce
I have created a simple project here that demonstrates the issue.
Simply run the app in a web browser and try typing "john doe" with a space between "john" and "doe", and you will see that the space is ignored. Do the same thing on iOS and it works fine.

Expected behavior
I would expect this text field to allow space characters on all platforms, because I am using this field to add custom values on the fly so I need to be able to type arbitrary text

Library version, Flutter version, platform
Library version: 1.1.0
Flutter version: 3.10.0
Platform: web and ios

@nlfiedler
Copy link
Owner

My application is web-based as well and this is a problem for me, so I will be focusing on this issue. Aside from iOS, also works on macos, so seems specific to the web. There is some code in the widget that is web/not-web specific but changing the conditions did nothing. However, the patch below made some progress at least. However, something promptly filters the spaces on the next non-space entered. I can't tell what is doing this, I don't see anything too obvious in the widget, it may be in flutter itself.

diff --git a/lib/src/chips_input.dart b/lib/src/chips_input.dart
index 3cc4cf89..384b8d9b 100644
--- a/lib/src/chips_input.dart
+++ b/lib/src/chips_input.dart
@@ -556,6 +556,13 @@ class ChipsInputState<T> extends State<ChipsInput<T>> with TextInputClient {
           final sd = str.substring(0, str.length - 1);
           final sel = TextSelection.collapsed(offset: sd.length);
           updateEditingValue(TextEditingValue(text: sd, selection: sel));
+        } else if (kIsWeb &&
+            event.runtimeType.toString() == 'RawKeyDownEvent' &&
+            event.logicalKey == LogicalKeyboardKey.space) {
+          // TODO: sort of works, except next non-space character makes all spaces disappear
+          final sd = '$str ';
+          final sel = TextSelection.collapsed(offset: sd.length);
+          updateEditingValue(TextEditingValue(text: sd, selection: sel));
         }
       },
       child: NotificationListener<SizeChangedLayoutNotification>(

@sarbogast
Copy link
Contributor Author

Did you find what was wrong? Because your component is the only one that has all the right features, other similar inputs are just buggy af or not maintained anymore, so I don't have any alternative.

@nlfiedler
Copy link
Owner

I haven't had much time for personal projects lately, so I haven't been able to debug this any further. It seems clear to me that something platform-specific is happening within Flutter, as it works fine on anything but the web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants