Closed jahorton closed 3 months ago
Test specification and instructions
Notes from demo today: would be nice for suggestions not at the left of screen to hold position and have the banner correspondingly 'scroll left'. (Unless it's the left-most option, of course.)
Variable-width options would be nice, too. (Personal note: would likely be as a child PR.)
The new commit adds two new features (4 and 5 above).
In short, it adds initial support for variable-width suggestions on the banner along with some polish for cases where too few suggestions are available to cover the full banner width.
At 200x400:
At iPhone SE resolution:
Contrast "and" with "I" - "and" is clearly wider. The padding amounts are equal, though.
The banner is scrollable for neither; the suggestion are padded just enough to fill with width, but no further.
Alternate cases:
The banner above is not scrollable; there are only two selectable options. (The excess separators are also hidden.)
Words that are short enough use only as much space as needed, while overly long words are collapsed. Max width is set to 1/3 the banner's width, so "completely" is partially obscured. This banner scrolls, since additional suggestions are available past the margin.
Some notes toward further work:
While modern browsers support 'transitionstart'
and 'transitionend'
events we could try to tap, those events aren't supported on some of the older devices we aim to support:
https://developer.mozilla.org/en-US/docs/Web/API/Element/transitionstart_event#browser_compatibility
Note: Chrome for Android @ v74, Safari on iOS @ 13.4.
Also, there's no related event nor event property I can find that would actually let us inspect the progress of the transition to ensure any, uh, "counter scrolling" on the banner would be perfectly synchronized.
Just in case, for clarity: "counter scrolling" here = scrolling the banner left exactly as much as the suggestion would "slide" right when expanding. One of the ideas we floated in design meetings was to keep the touchpoint stationary, but the option-expansion technique we're using requires expanding to the right; we'd need that counter scroll to offset the location change.
A better way forward, even though it has a higher up-front cost: refer to https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#examples.
requestAnimationFrame
is an older, more thoroughly supported method designed to facilitate transitions and animations from JS. Since we'd have to use this anyway for the banner's "counter scroll", we may as well use it to handle suggestion expanding & collapsing too. That would give us direct access to the state of the transition, which we a CSS-only implementation does not make available, which means we'd have the exact data needed to make a perfect "counter scroll."
After a lot of work + experimentation, I think I've finally gotten something nice working for offsetting scrolls to promote expanded option visibility. The logic seems in place for LTR scripts, but I've yet to do it for RTL ones. I'm quite happy with its current form, but it took way longer to get all of the details and polish right than I'd like to admit.
Newly-added effects:
.scrollLeft
limitations, as .scrollLeft
typically avoids sub-pixel values.
RTL scroll offsetting is now in place.
And, partly because I can't leave well enough alone, I've followed up by allowing variable-width suggestion functionality to interact with everything else.
A few highlights when using a highly-restricted screen resolution:
In both cases, only three suggestions were available, so the variable-width subsystem allocated width where it'd be needed most. That got split across both longer "butterfly" suggestions, while the "rollercoaster" suggestion was the only long one in its set, allowing it to hog the extra width. The "collapsed" suggestions are still expandable, and scrolling is possible while they're expanded.
As is already noticeable above, this facilitates narrowing the space allocated to short suggestions. For a more extreme case:
That's right... seven default suggestions fit in the banner in this highly-restrictive resolution! Since most devices have markedly more space available, I've upped the max number of suggestions to display up to 8:
Also...
When suggestions run long enough that all require "collapsing", three will display, with the rest available via scrolling.
Of course, there are definitely in-between states.
Admittedly, allowing suggestions to be narrowed significantly reduces the average amount of whitespace, so a little extra padding around the text of each suggestion may be in order.
Notable bugs when experimenting on a real device:
Huh, that second option's acting really funny, though I didn't do any notable setup to trigger that scenario.
Highlighting it triggers the usual animations, which will start from a properly-collapsed state. This causes a "snapping" / "jumping" behavior because it's showing up expanded before selection (unlike the suggestion to its left) instead, and the animation start forces the implied jump.
If one suggestion is held, then another one tapped, the banner's state management kinda breaks; multi-tap will definitely need testing.
Per @mcdurdin's recent comment on a related precursor PR: https://github.com/keymanapp/keyman/pull/7906#issuecomment-1669118412:
Note, see #3003, #5671, #2220 and determine if this along with #7934 is along to close these.
To your kind notice.
https://github.com/keymanapp/keyman/issues/2220#issuecomment-1666183336
☝️This is in iOS 17, Apple has implemented in Kannada Transliteration Keyboard.
Continuous word suggestions in single line, words spaced by "wide white space" (5 spaces)
and to the right corner of the banner, a downward arrow to indicate more suggestions. When tapped on the downward arrow, multi-line suggestion field is presented.
5 Transliteration suggestions Plus 1 as is English word is presented, since it's transliteration keyboard
Keyman could opt for UPTO 5 suggestions
Downward key is presented only when 5+1 words do not fit the single line
Here is a case where, all 6 words fits in one line
Here is a case where only 4+1 words are presented.
I have just updated this PR to be based on current work... aside from all the gestures stuff. It'll need adjustments to work alongside that as well, but such followup-adjustments should be simpler than the update I just did.
Re https://github.com/keymanapp/keyman/pull/7934#issuecomment-1813589084:
... aside from all the gestures stuff. It'll need adjustments to work alongside that as well, but such followup-adjustments should be simpler than the update I just did.
A post-gesture variant of this PR is now available as feat/web/fancy-suggestion-banner-megamerge
. I'm not making it into a PR though, as we consider it separate from all the 🐵 gesture work. Its changes will be applied here once #7324 is merged to master
, resolving all the to-be merge-conflicts, after which this PR will be taken out of draft.
@jahorton please check the implementation in iOS, it expands the suggestion bar to multi-line.
This would be neat for complex scripts which have long words
https://github.com/keymanapp/keyman/assets/14062593/6842b8df-b6c6-4e5a-b3f6-f559c77b0b51
We've opted for a slightly different approach, but it should meet the same goals. Since it may not be super-clear from pictures...
For something super-restrictive:
I've gone ahead and updated the main description with these animated-gif recordings.
Could we have both the methods, option to keyboard development.
The last commit fixes something subtle I noticed in the current screen-recordings - the banner's scroll position wasn't being reset when a later suggestion (that required scrolling to reach) was selected.
Granted, this only matters if the screen resolution is so low that the default suggestion set overflows screen width; if it doesn't, that fact in itself will force a scroll-position reset.
..suggestion banner 1
..1 or 2 suggestions on the banner
TEST_LOW_RES_EMULATION (FAILED): Tested using KeymanWeb testing page in the chrome emulation page and here is my observation: 1. Created the custom mobile device with a resolution "200x400". 2. Typed "comp" in the text area box and I noticed that there is no predictive text appearing in the suggestion banner. Seems to be an issue.
Test Results
- TEST_LOW_RES_EMULATION (FAILED): Tested using KeymanWeb testing page in the chrome emulation page and here is my observation: 1. Created the custom mobile device with a resolution "200x400". 2. Typed "comp" in the text area box and I noticed that there is no predictive text appearing in the suggestion banner. Seems to be an issue.
Error in the JS console:
GET https://build.palaso.org/repository/download/Keymanweb_TestPullRequests/435384:id/src/test/manual/web/prediction-mtnt/index.htmlnrc.en.mtnt.model.js
Status: 404
Since the bad part's near the end...
prediction-mtnt/index.htmlnrc.en.mtnt.model.js
Looks like the actual page's URL got mashed into the model's URL for some reason.
It appears a related change happened with #9953. Not sure why we'd have only caught this now, but at least it is caught now.
@keymanapp-test-bot retest TEST_LOW_RES_EMULATION
I've fixed the model-linkage issue for the testing page; you should get suggestions now.
..Android Mobile with custom resolution
..iPhone SE
..iPad Mini
..Android Mobile
..Android Tablet
Changes in this pull request will be available for download in Keyman version 17.0.249-alpha
Fixes #9371.
This PR adds the following features to the predictive-text suggestion banner:
If all suggestions are short (i.e, the sum width is less than that of the full banner width), padding will be added evenly to each to space them out nicely.
Examples for points 4 and 5 may be found in this comment below.
One example (drop-down)
![image](https://github.com/keymanapp/keyman/assets/25213402/2ff123c5-991a-45ea-aab3-306eb6f3607a)So, what does this look like in practice?
Under a super-low screen resolution (drop-down)
![low-res-understanding](https://github.com/keymanapp/keyman/assets/25213402/55290a34-da87-4a4b-85ba-74cd7b84dc0d) Note the initial position of the touch: when things seem "sticky" once the word `understanding` is selected. We believe the most natural interaction is to expect the suggestion to generally stay at the same place (when reasonable) underneath your finger. That's the part you originally saw before the touch started, so that part is sure to have already been visible; if the suggestion was forced / clamped into view, a different part you hadn't seen could end up underneath your finger instead. We want to ensure you have a chance to see that previously-hidden part by moving your finger during the clamped-movement state, as you would have been able to see it without issue if you touched the suggestion when it wasn't near screen borders. The suggestion wants to stay at the same position underneath the touchpoint, but it wants to show itself initially even more so that you have as much info as possible. As the touchpoint is returned to the same initial position over the suggestion's word - the last `n` - the "sticky" aspect is progressively dropped.At iPhone SE resolution (drop-down)
![high-res-understanding](https://github.com/keymanapp/keyman/assets/25213402/5ff3f265-bd9c-4929-9486-948f8d545238)Examples
(from an older version of this PR, with less aggressive fading effects)
Note that these examples were derived from Chrome's mobile-device emulation mode, set to Repsonsive 200x400. (While not directly matching an existing device, this allows comparatively shorter words to overrun their boundaries within the banner.)
All suggestions collapsed:
Upon pressing down on one:
And with a little scrolling in the mix (with a different 'selection'):
User Testing
TEST_ANDROID_LTR: Using the Android app on a mobile device - preferably one with low resolution - test the banner to ensure it works properly.
sil_euro_latin
as the keyboard, here are some useful word roots to experiment with:TEST_ANDROID_RTL: Using the Android app on a mobile device - preferably one with low resolution - test the banner to ensure it works properly.
balochi_phonetic
as the keyboard, play with the banner and report if anything seems "wrong" with the banner.اِسراییلیانی
a
v
s
r
a
y
y
l
y
a
n
y
TEST_LOW_RES_EMULATION: Using Chrome mobile-device emulation and the "Predictive text - robust testing" Web testing page, test the banner at a low resolution to ensure it works properly.
Personal testing notes
Some of the ways I've played / tested the banner myself:
other things to test: