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): better element inputmode management 📴 #7395

Merged
merged 6 commits into from
Oct 17, 2022

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented Oct 4, 2022

Refer to #7343 (comment).

If a website designer would normally be specifying input mode for elements that KMW will be managing, we should put forth a good-faith effort to remember what the page's original settings were. At some point, we might even go so far as to support 'intent' behavior in KMW... but not this release cycle.

As proper user-testing would be a lot of work to facilitate here, for now...
@keymanapp-test-bot skip

@jahorton jahorton added this to the A16S12 milestone Oct 4, 2022
@keymanapp-test-bot keymanapp-test-bot bot added the user-test-missing User tests have not yet been defined for the PR label Oct 4, 2022
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Oct 4, 2022

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.

I appreciate this design. You are trying to prevent inputMode from being overwritten by other Javascript code, which would stop Keyman from working.

My only real concern is that while we are preventing the symptoms of a problem here, the other code is not going to expect that setting inputMode can ever "fail" (from their perspective), and so web site developers may still end up with potentially strange behaviours.

So ... whether we go with an observer (which is more complex and more potential for maintenance pain...), or with the naive save/restore approach which was in my mind originally, we're going to need to document this interaction for website devs.

Hope that makes sense! All that said, I'm happy with whatever you decide. Just wanted to flag the potential for weirdness.

@jahorton
Copy link
Contributor Author

jahorton commented Oct 5, 2022

I appreciate this design. You are trying to prevent inputMode from being overwritten by other Javascript code, which would stop Keyman from working.

Not just that - long-term perspective, it'll store updates to the field's intended inputmode. Should we ever support any form of "intents" within KeymanWeb, we could also use that stored value to drive intent-based behaviors. The funky caveat is that we'd need a way to let page devs retrieve their prescribed inputmode.

I wonder if setting inputmode = none only on element focus & removing it on element blur would still hide a device's native OSK while allowing the property to be available most of the time to page devs. But that could get complex and/or brittle. Probably better to just provide a get/set keymanInputMode or something if and when the time comes.

@mcdurdin
Copy link
Member

mcdurdin commented Oct 6, 2022

Probably better to just provide a get/set keymanInputMode or something if and when the time comes.

Yes. We can't develop in a vacuum. Better to give site developers the tools to connect the dots between their frameworks and Keyman input method than to try and 'magically' make it work ... magic will only get us so far, and then it breaks badly!

@mcdurdin mcdurdin modified the milestones: A16S12, A16S13 Oct 16, 2022
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.

So, a bunch of minor bit and pieces. At first I thought it was all fine, but I think there is potentially an issue on line 330 of domManager.ts; everything else is just cleanup.

@@ -907,6 +922,30 @@ namespace com.keyman.dom {
}
}.bind(this);

_InputModeObserverCore = function(this: DOMManager, mutations: MutationRecord[]) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining the purpose of this function? Also I think we should be naming it _inputModeObserverCore?

Copy link
Contributor Author

@jahorton jahorton Oct 17, 2022

Choose a reason for hiding this comment

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

The other observer core functions have similar capitalization:

  • _AutoAttachObserverCore
  • _EnablementMutationObserverCore

Should I change them, too?

Copy link
Member

Choose a reason for hiding this comment

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

Should I change them, too?

It's probably good sanitisation to iteratively cleanup to javaScript camelCasing preference, so yeah, if it's not too big a yak shave, sure!

@@ -233,7 +241,6 @@ namespace com.keyman.dom {

if(!this.isAttached(Pelem)) {
this.setupElementAttachment(Pelem);
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be done again in enableInputElement(), called on line 247, albeit in a more nuanced manner (handling iframes)

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

@jahorton jahorton marked this pull request as ready for review October 17, 2022 03:17
@jahorton jahorton requested a review from sgschantz as a code owner October 17, 2022 03:17
@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-missing User tests have not yet been defined for the PR label Oct 17, 2022
Base automatically changed from change/web/drop-alignInputs to master October 17, 2022 03:19
@jahorton jahorton merged commit c690ed7 into master Oct 17, 2022
@jahorton jahorton deleted the fix/web/touch-inputmode-preservation branch October 17, 2022 03:19
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 16.0.82-alpha

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.

3 participants