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

fix(web): prevents selection-clear for pure layer-switching multitaps #11232

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented Apr 17, 2024

Fixes #11230.

Previously, we always cleared the selection as part of resetting the context-state for multitaps. Problem is... that has unwanted cross-effects if the only thing the multitap is doing is to layer-switch.

It's possible to shorten the changes with a "naive" fix, but naive solutions don't account for potential deadkey solutions very well. I figure it's best to nip all such issues in the bud now, especially since I don't think there are related preventative warnings and/or errors for keyboard developers in Developer.

User Testing

Any Web-based touch-platform will suffice for these tests.

TEST_CAPS_WITH_SELECTION: Verify that selected text is not erased when double-tapping SHIFT to enter a keyboard's caps-lock state. (A direct repro attempt for #11230.)

TEST_MULTITAP_ROTA: Using a keyboard with multitap keys that output text, verify that the output text is properly replaced on each tap.

@keymanapp-test-bot keymanapp-test-bot bot added the user-test-missing User tests have not yet been defined for the PR label Apr 17, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Apr 17, 2024

User Test Results

Test specification and instructions

  • TEST_CAPS_WITH_SELECTION (PASSED): Tested with the attached PR build (Keyman 17.0.309-beta-test-11232) on an iPhone 13 mobile device and here is my observation: 1. Opened the Keyman In-app. 2. Entered some texts. 3. Selected a word from it. 4. Double-tapped the Shift key and verified that the selected word still appeared on the text input screen. Seems to be working as expected.
  • TEST_MULTITAP_ROTA (PASSED): Tested with the attached PR build (Keyman 17.0.309-beta-test-11232) on an iPhone 13 mobile device and here is my observation: 1. Installed ye_old_ten_key and diacritic_rota keyboards from the given link. 2. Restarted Keyman In-app. 3. Switched to ye_old_ten_key keyboard. 4. Verified that the output text is properly replaced on each tap. 5. Switched to diacritic_rota keyboard and verified that using the multitap keys showed the output text that is properly replaced on each tap. Seems to be working as expected. FYI, When the Shift layer is ON, double tap num 7 key showed number 7 on the screen. But, double tap on num 0(zero) or .(period) outputs some other special characters like ),>.

// Has there been a context change at any point during the multitap? If so, we need
// to revert it. If not, we assume it's a layer-change multitap, in which case
// no such reset is needed.
if(!isEmptyTransform(transcription.transform) || !transcription.preInput.isEqual(Mock.from(outputTarget))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why both?

  1. transcription.transform (and in fact, transcription in general) does not provide any indication of deadkey changes.
  2. While certainly "bad keyboard design", there's nothing preventing a multitap component of a layer-switch key from manipulating the context. Should that occur, the correct thing to do is still to rewind the context.

Note that it is technically possible to have altered the context since the base tap... but if the current context state matches the original one anyway, there's no need to perform a reset - we've already done the rewind in one manner or other.


We're only safe to bypass the context-rewind mechanism if there truly has been no change to the context whatsoever. Deadkey changes are context changes, and to handle them requires the some of the special handling newly added by this PR.

return this.text == other.text
&& this.selStart == other.selStart
&& this.selEnd == other.selEnd
&& this.deadkeys().equal(other.deadkeys());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If someone goes and makes a multitap key that only does deadkey stuff, the final check is required to be able to rewind deadkey manipulations. Otherwise, we'd get a lot of excess deadkeys during such a multitap due to not erasing deadkeys from taps before the final one.

@jahorton jahorton marked this pull request as ready for review April 17, 2024 03:41
@jahorton jahorton requested a review from mcdurdin as a code owner April 17, 2024 03:41
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed and removed user-test-missing User tests have not yet been defined for the PR labels Apr 17, 2024
@jahorton jahorton linked an issue Apr 17, 2024 that may be closed by this pull request
@bharanidharanj
Copy link

Test Results

  • TEST_CAPS_WITH_SELECTION (PASSED): Tested with the attached PR build (Keyman 17.0.309-beta-test-11232) on an iPhone 13 mobile device and here is my observation: 1. Opened the Keyman In-app. 2. Entered some texts. 3. Selected a word from it. 4. Double-tapped the Shift key and verified that the selected word still appeared on the text input screen. Seems to be working as expected.

Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

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

LGTM

@bharanidharanj
Copy link

@jahorton Tested the same in an Android 13 Mobile and it seems to be working as expected.

@bharanidharanj
Copy link

Test Results

  • TEST_MULTITAP_ROTA (PASSED): Tested with the attached PR build (Keyman 17.0.309-beta-test-11232) on an iPhone 13 mobile device and here is my observation: 1. Installed ye_old_ten_key and diacritic_rota keyboards from the given link. 2. Restarted Keyman In-app. 3. Switched to ye_old_ten_key keyboard. 4. Verified that the output text is properly replaced on each tap. 5. Switched to diacritic_rota keyboard and verified that using the multitap keys showed the output text that is properly replaced on each tap. Seems to be working as expected. FYI, When the Shift layer is ON, double tap num 7 key showed number 7 on the screen. But, double tap on num 0(zero) or .(period) outputs some other special characters like ),>.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Apr 17, 2024
@jahorton jahorton merged commit 5005339 into beta Apr 17, 2024
20 checks passed
@jahorton jahorton deleted the fix/web/no-selection-clear-on-caps-multitap branch April 17, 2024 10:43
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.309-beta

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

Successfully merging this pull request may close these issues.

bug(web): layer-switching key multitaps clear selected text
4 participants