Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@bleroux
Copy link
Contributor

@bleroux bleroux commented May 10, 2023

Description

This PR updates the Linux text input plugin to avoid adding a new line on a multiline text field when action is not set to TextInputAction.newline.

Related Issue

Linux implementation for flutter/flutter#125879

Tests

Adds 1 test.

case GDK_KEY_ISO_Enter:
if (priv->input_type == kFlTextInputTypeMultiline) {
if (priv->input_type == kFlTextInputTypeMultiline &&
strcmp(priv->input_action, kFlTextInputActionSend) != 0) {
Copy link
Member

Choose a reason for hiding this comment

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

should we rather compare to "TextInputAction.newline" because it's probably the only text input action that should insert "\n"?

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems to make sense to me after looking through all of the other TextInputAction values. That's also the default for multiline fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we rather compare to "TextInputAction.newline" because it's probably the only text input action that should insert "\n"?

I wanted to be as conservative as possible because I'm not sure about the meaning of all the TextInputAction values on desktop.
But I agree that it would make sense to insert "\n" only when action is TextInputAction.newline.

@justinmc Can you confirm it would be preferable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I agree 👍. So to be specific, I think you should keep the multiline check, and instead of checking that it's not kFlTextInputActionSend, check that it is the newline action.

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Will the solution be basically the same on all of the other platforms?

CC @cbracken in case you or anyone else more familiar with the engine wants to take a look.

case GDK_KEY_ISO_Enter:
if (priv->input_type == kFlTextInputTypeMultiline) {
if (priv->input_type == kFlTextInputTypeMultiline &&
strcmp(priv->input_action, kFlTextInputActionSend) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems to make sense to me after looking through all of the other TextInputAction values. That's also the default for multiline fields.

static constexpr char kMultilineInputType[] = "TextInputType.multiline";
static constexpr char kNoneInputType[] = "TextInputType.none";

static constexpr char kFlTextInputActionSend[] = "TextInputAction.send";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Maybe kSendInputType in order to align with the other input type constants above?

@bleroux
Copy link
Contributor Author

bleroux commented May 10, 2023

Will the solution be basically the same on all of the other platforms?

Yes. I have a PR almost ready for macOS. I worked on something similar for Flutter Web months ago. And I looked quickly at the Windows implementation, it is very similar. The main work here is to write the platform specific test.

So the main point is to agree if we want to add '\n' only for multiline text field with TextInputAction.newline? If so, I will update this PR and once it is merged I will file PRs for the other platforms.

@chinmaygarde
Copy link
Member

@justinmc Do we have concensus on @bleroux s point? We can file issues for other platforms and land this.

@bleroux bleroux requested a review from justinmc May 11, 2023 20:53
Copy link
Member

@jpnurmi jpnurmi left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

Nice - thanks for the fix @bleroux!

@justinmc justinmc merged commit ef5c349 into flutter:main May 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 12, 2023
…126624)

flutter/engine@748ef96...ef5c349

2023-05-11 [email protected] [Linux - TextInput] Do not add new line for send action (flutter/engine#41895)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@bleroux bleroux deleted the linux_do_not_add_newline_when_action_is_send branch May 12, 2023 06:45
auto-submit bot pushed a commit that referenced this pull request May 13, 2023
…#41977)

## Description

This PR updates the macOS text input plugin to avoid adding a new line on a multiline text field when action is not set to `TextInputAction.newline`.

## Related Issue

macOS implementation for flutter/flutter#125879.
(similar to the Linux implementation in #41895).

## Tests

Adds 2 tests.
CaseyHillers pushed a commit to CaseyHillers/flutter that referenced this pull request May 24, 2023
…lutter#126624)

flutter/engine@748ef96...ef5c349

2023-05-11 [email protected] [Linux - TextInput] Do not add new line for send action (flutter/engine#41895)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit that referenced this pull request Jun 1, 2023
…ne (#42244)

## Description

This PR updates the Windows text input plugin to avoid adding a new line on a multiline text field when action is not set to `TextInputAction.newline`.

## Related Issue

Fixes flutter/flutter#125879 as Linux and macOS implementations are merged.
Linux PR: #41895
macOS PR: #41977

## Tests

Adds 2 tests.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants