Skip to content

fix: Fix InputScope issues on Android and Wasm - #7074

Merged
jeromelaban merged 4 commits into
unoplatform:feature/api-alignmentsfrom
Youssef1313:issues/5207
Oct 20, 2021
Merged

jeromelaban merged 4 commits into
unoplatform:feature/api-alignmentsfrom
Youssef1313:issues/5207

Conversation

@Youssef1313

@Youssef1313 Youssef1313 commented Sep 14, 2021 •

Copy link
Copy Markdown
Member

GitHub Issue (If applicable): closes #5207, closes #2557, closes #1389

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

On Android:

  • InputScope maps to inputTypes on Android, which does validation.

On Wasm:

  • InputScope doesn't do anything.

What is the new behavior?

On Android:

  • Use SetRawInputType, which only changes the keyboard but allows any input.

On Wasm:

  • Use inputmode attribute which changes the keyboard but allows any input.

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

I didn't find a way to test how the keyboard shows (at best to my knowledge, we can only validate that any input is allowed).

Internal Issue (If applicable):

@Youssef1313
Youssef1313 requested a review from a team September 14, 2021 14:59
@gitpod-io

gitpod-io Bot commented Sep 14, 2021

Copy link
Copy Markdown

if (_textBoxView != null)
{
_textBoxView.InputType = types;
_textBoxView.SetRawInputType(types);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is likely to be a breaking change for application current expecting uno to do the validation. This new behavior is likely to be the right one, though. We should be placing this behind a feature flag.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jeromelaban To be more clear about the current behavior, we indeed was mapping to an Android API that does validation, but somehow, Uno managed to skip/override the native validation(probably this? not sure), but anyway the result was the cursor moving to the beginning after every invalid character.

So I don't expect anyone to be relying on the current behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree that the behavior is different yet the actual keyboard behavior is different from the SIP where the characters don't show at all (and the cursor position does not change). It'd be best to have this specific change behind a disabled flag, mark it as a breaking change in the conventional commit and explain how the flag works.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

where the characters don't show at all (and the cursor position does not change)

I'm not sure what SIP is, but this is not the current behavior nor the new behavior per my testing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SIP is Soft Input Panel (the on-screen keyboard). The old behavior was that keys outside the input type would not be entered at all if using a physical keyboard (and the cursor would not more).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jeromelaban Thanks, got it and addressed the feedback.

@Youssef1313
Youssef1313 force-pushed the issues/5207 branch 2 times, most recently from 99f024e to 8024261 Compare September 21, 2021 16:26
BREAKING CHANGE: Introduces a breaking change for InputScope that is controlled by FeatureConfiguration.TextBox.UseLegacyInputScope
@jeromelaban

Copy link
Copy Markdown
Member

Looks like the failing tests are related to this issue: TextBox_IsReadOnly_AcceptsReturn_Test and TextBox_AutoGrow_Vertically_Test on android. Can you take a look ?

@Youssef1313

Copy link
Copy Markdown
Member Author

@jeromelaban I looked at TextBox_IsReadOnly_AcceptsReturn_Test. It seems like the old behavior doesn't match UWP, but the new behavior does? BUT there might be other non-tested broken cases. I'm also completely unsure how this change can affect AcceptsReturn.

In UWP:

<TextBox x:Name="TargetTextBox"
	AcceptsReturn="True"
	IsReadOnly="True"
	Text="lorem&#x0a;ipsum" />

and

<TextBox x:Name="TargetTextBox"
	Text="lorem&#x0a;ipsum"
	AcceptsReturn="True"
	IsReadOnly="True" />

are different. The order of setting properties matters here because Text seems to be cutting the extra lines from the property value itself (not only visually) when AcceptsReturn is false.

The failing test is setting the text first, so the text gets cut to one line only. So the expectation of height differences is NOT correct for this particular test.

The actual case that might be regressing is when AcceptsReturn is set first.

@jeromelaban
jeromelaban changed the base branch from master to feature/api-alignments October 18, 2021 13:08
@jeromelaban

Copy link
Copy Markdown
Member

Let's move this PR to the API alignments branch, as it is a subtle breaking change.

@jeromelaban

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jeromelaban
jeromelaban merged commit 1ce4451 into unoplatform:feature/api-alignments Oct 20, 2021
@Youssef1313
Youssef1313 deleted the issues/5207 branch October 20, 2021 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants