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): correctly handle cross-origin stylesheets when calculating keyboard size and key cap font size #11472

Merged
merged 1 commit into from
May 30, 2024

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented May 17, 2024

Fixes #11467.

This is intended to be merged together with keymanapp/help.keyman.com#1272, which fixes another facet of the same set of issues.

The issue was arising due to cross-origin stylesheet security. So, a different pattern to detect stylesheet loading is needed. Upon re-examining of the sources that led to the prior solution... much of it was StackOverflow from about a decade back, oriented toward much older browsers than we have today. At the time, <link> elements didn't consistently support onload on all browsers... but that has since been rectified. It appears that we can do this more simply than I previously thought.

Additionally, this fixes a follow-up issue that occurred once #11467 was fixed. The way that help.keyman.com loads keyboard-documentation pages (up until now) bypasses use of any keyboard stub; the OSK conditions on that stub and certain properties of it in order to provide font information. In fact, in our initial 17.0 release, it also conditioned application of the SpecialOSK font styling upon this as well! This has been fixed, though keymanapp/help.keyman.com#1272 will also ensure that the information actually is available when run on help.keyman.com keyboard-documentation pages.

User Testing

TEST_DOC_RENDERING: Using the "Tests keyboard documentation rendering" test page, use Developer mode (via F12) and verify that the page loads without displaying any error messages.

We'd also like to verify that this fixes the page mentioned in the base issue (#11467) - https://help.keyman.com/keyboard/basic_kbdhe220/1.1/basic_kbdhe220 - but that will require this PR, keymanapp/help.keyman.com#1271, and keymanapp/help.keyman.com#1272 to be merged in for a proper test.

@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels May 17, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented May 17, 2024

@dinakaranr
Copy link

Test Results

  • TEST_DOC_RENDERING (PASSED): I tested this issue with the attached "KeymanWeb Test Home" build on the Chrome browser (Windows OS): Here is my observation.
  1. Open the Chrome browser and open the developer tool by pressing the F12 key.
  2. Paste the "https://build.palaso.org/repository/download/Keymanweb_TestPullRequests/463931:id/index.html" URL in the address bar.
  3. Click the "View Keymanweb website-oriented manual test pages" link button.
  4. Click the "Tests keyboard documentation rendering" link button. (src/test/manual/web/index.html)
  5. Navigation happens in "build-visual-keyboard/index.html"
    Here, no error appears on the console tab. The page is rendering correctly without error, and all keyboards appear on the browser. It works well. Thanks.

Navigate to the "https://help.keyman.com/keyboard/basic_kbdhe220/1.1/basic_kbdhe220" URL on another tab.
An error appears on the console tab after rendering completion
So, The 11467 PR failed as of now. Thanks.
Please refer to the screenshot

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label May 17, 2024
@mcdurdin
Copy link
Member

Note: once this lands in 17.0-stable, then we should remove the temporary patch applied in keymanapp/help.keyman.com#1278

@mcdurdin mcdurdin changed the title fix(web): fixes kbd-help documentation for help.keyman.com fix(web): correctly handle cross-origin stylesheets when calculating keyboard size and key cap font size May 18, 2024
@jahorton
Copy link
Contributor Author

Navigate to the "https://help.keyman.com/keyboard/basic_kbdhe220/1.1/basic_kbdhe220" URL on another tab.
An error appears on the console tab after rendering completion
So, The 11467 PR failed as of now. Thanks.
Please refer to the screenshot

Well, it hasn't been merged in yet, so it naturally failed - the changes don't exist for the help site.

[...] but that will require this PR, keymanapp/help.keyman.com#1271, and keymanapp/help.keyman.com#1272 to be merged in for a proper test.

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 I think

Comment on lines +1380 to +1382
// For help.keyman.com, sometimes we aren't given a stub for the keyboard.
// We can't get the keyboard's fonts correct in that case, but we can
// at least proceed safely.
Copy link
Member

Choose a reason for hiding this comment

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

Putting a fix into KeymanWeb specifically for help.keyman.com indicates that we need to:

  1. Extend the support for different patterns of use such as on help.keyman.com, or
  2. Fix help.keyman.com to match supported documentation.

The one thing we really shouldn't be doing is adding site-specific patches to Keyman Engine for Web itself. Either it's generally supported or it is not supported.

Or is this a more general comment that just happens to reference help.keyman.com?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's citing a specific case that has occurred that can cause KMW to throw errors... when it doesn't really have to do that. We can relax and proceed if we don't worry about having perfect font info.

@mcdurdin mcdurdin modified the milestones: A18S2, A18S3 May 24, 2024
jahorton added a commit that referenced this pull request May 30, 2024
@jahorton jahorton merged commit b6d27d0 into master May 30, 2024
20 checks passed
@jahorton jahorton deleted the fix/web/kbd-doc-generation branch May 30, 2024 06:59
@keyman-server
Copy link
Collaborator

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

3 similar comments
@keyman-server
Copy link
Collaborator

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

@keyman-server
Copy link
Collaborator

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

@keyman-server
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants