-
-
Notifications
You must be signed in to change notification settings - Fork 103
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): position popups correctly in landscape mode on Android and during Chrome emulation #5075
Conversation
web/source/osk/visualKeyboard.ts
Outdated
@@ -1789,8 +1789,12 @@ namespace com.keyman.osk { | |||
|
|||
// And correct its position with respect to that element | |||
ss=subKeys.style; | |||
var x=dom.Utils.getAbsoluteX(e)+0.5*(e.offsetWidth-subKeys.offsetWidth), y, | |||
xMax=(util.landscapeView()?screen.height:screen.width)-subKeys.offsetWidth; | |||
var x=dom.Utils.getAbsoluteX(e)+0.5*(e.offsetWidth-subKeys.offsetWidth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var y
is no longer defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS Code indicates that the variable was unused, so yes.
web/source/osk/visualKeyboard.ts
Outdated
var x=dom.Utils.getAbsoluteX(e)+0.5*(e.offsetWidth-subKeys.offsetWidth); | ||
|
||
// https://stackoverflow.com/questions/28083715/how-to-detect-if-a-mobile-device-is-emulated-by-google-chrome | ||
// (Note the last reply to the accepted answer.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// (Note the last reply to the accepted answer.) | |
// Note in particular https://stackoverflow.com/questions/28083715/#comment108747578_28084346: | |
// The definitive way to determine this is to check for `navigator.maxTouchPoints > 1` Because Chrome | |
// emulated devices will always have only 1 touchpoint (ie. your mouse cursor), while actual (modern) | |
// mobile devices will always have more than 1, and devices without touch support will always have | |
// 0. – Ivan [CC-BY-SA 4.0] |
And yet I wonder if this is true on a Windows computer with a touch screen.
I will try and test this on my wife's touch-screen laptop shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If false
in that case, it'll still fail during Chrome emulation of an iOS device. Fortunately, all standard user use-cases will be fine, though it could affect keyboard developers like Makara when using the Developer test host.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have verified that navigator.maxTouchPoints
is 10 on my wife's computer when mobile emulation is not running, but it is 1 when mobile emulation is running. So that's good news.
Suggest changing title to clarify what this is fixing, e.g. "fix(web): position popups correctly in landscape mode on Android and Chrome emulation"? |
I'm trying to get a full picture of the possible scenarios we are trying to support, and the differences between them:
Is that a comprehensive list? Is there a table we can draw up of the differences between the values we are relying on? (If possible, we should file a bug against Chrome if its emulation of iPhone/iPad mismatches.) Also:
|
OK, I can repro that effect when targeting a Pixel 2. (It didn't show up when targeting a Nexus.) |
Tested on Android Emulator (Pixel 2 API 29, Android 10). The popped key on the top right corner behaves as expected within Keyman app on landscape mode. The same normal/expected behavior is observed when using it as a system keyboard on landscape mode. Still figure out how to test "Non-embedded test". I will get back to this first thing this afternoon. |
var x=dom.Utils.getAbsoluteX(e)+0.5*(e.offsetWidth-subKeys.offsetWidth), y, | ||
xMax=(util.landscapeView()?screen.height:screen.width)-subKeys.offsetWidth; | ||
var x = dom.Utils.getAbsoluteX(e)+0.5*(e.offsetWidth-subKeys.offsetWidth); | ||
var xMax = keyman.osk.getWidth() - subKeys.offsetWidth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, liking this more than the previous iteration! 😂
I usually prefer to not have |
Non-embedded testTested using The popped up keys are shown directly on the based key on the top right corner. It is working as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Tested on Android physical device now with good results as well as on Chrome with various devices all in landscape and portrait, and no problems encountered.
Does this potentially indicate a refactor of that code is in the future? |
I think we should cherry-pick to stable-14.0 :) |
I mean, yeah. OSK-Core work's going to affect more than a few things. There are other parts of the code that have been using the same approach; this just adds an extra to the list. |
Changes in this pull request will be available for download in Keyman version 15.0.48-alpha |
Fixes #4930.
To ensure this doesn't break anything for Android...
User Testing
@MakaraSok
I'm requesting two sets of tests. That said, I'd only expect an issue from the second (non-embedded) set if any issue occurs.
In-app test
Just fire up the Android app (from this PR's build) and ensure subkeys work as expected in landscape mode, both in-app and in system-keyboard mode. Behavior should be unaffected and match your default expectations.
Non-embedded test
This one's going to be a bit more involved, but reflects the actually-changed parts of the code.
localhost
on your machine.web/source
and run./build.sh
.localhost
setup.http://localhost/testing/unminified.html
.localhost
, type10.0.2.2
.10.0.2.2/localhost/testing/unminified.html
.A similar test may be run for steps 5 through 7 for those developing on Mac in order to test iOS device setups. (But without replacing
localhost
with10.0.2.2
.)Once the PR lands on
master
, this will become possible to test directly with keymanweb.com.