Skip to content

[Radio] Address a bug in Safari that causes the fade zone to partially overlay choice content#3644

Open
mark-fitzgerald wants to merge 3 commits into
mainfrom
LEMS-4147-handle-safari-zoom-bug-in-radio-widget
Open

[Radio] Address a bug in Safari that causes the fade zone to partially overlay choice content#3644
mark-fitzgerald wants to merge 3 commits into
mainfrom
LEMS-4147-handle-safari-zoom-bug-in-radio-widget

Conversation

@mark-fitzgerald
Copy link
Copy Markdown
Contributor

@mark-fitzgerald mark-fitzgerald commented May 19, 2026

Summary:

There is a bug in Safari that causes it to miscalculate/misreport the width of an element when it (or an ancestor) has zoom applied to it. This caused display issues with the Radio widget involving the horizontal scroll fade area (the fade would partially overlap the content). This PR includes the scale value being applied with the zoom property, as set in Frontend (PR is forthcoming).

NOTE: This PR relies upon a change in Frontend to work (PR #11403). This change in Perseus has a fallback for when the CSS variable is not in place (it's only there when in mobile on iOS), so there is no failure in normal web pages.

Issue: LEMS-4147

Test plan (local dev only):

  1. Open any radio widget exercise in Test Everything
  2. Append to the URL of the page the following (if one of the links above was not used) to simulate being in the web app with zoom being applied:
    • ?embedded=1&fontScale=0.8
  3. Note that the fade area is no longer overlapping the content

Affected UI:

Before

Screenshot 2026-05-20 at 12 50 16 PM

After

Screenshot 2026-05-20 at 12 50 26 PM

…Radio] Address a bug in Safari that causes the fade zone to partially overlay choice content
…tyling to account for the zoom property that is applied in the iOS app when users have their font size display smaller than normal.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

Size Change: 0 B

Total Size: 505 kB

ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.6 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.32 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 12.1 kB
packages/perseus-core/dist/es/index.js 26 kB
packages/perseus-editor/dist/es/index.js 104 kB
packages/perseus-linter/dist/es/index.js 9.41 kB
packages/perseus-score/dist/es/index.js 10 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 198 kB
packages/perseus/dist/es/strings.js 8.5 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (9947ea4) and published it to npm. You
can install it using the tag PR3644.

Example:

pnpm add @khanacademy/perseus@PR3644

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3644

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3644

@mark-fitzgerald mark-fitzgerald requested a review from a team May 20, 2026 19:53
…ing thickness (use REM).

Add a note to the fade area styling to explain the use of the mobile font scale variable.
Copy link
Copy Markdown
Contributor

@handeyeco handeyeco left a comment

Choose a reason for hiding this comment

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

I'm going to have to trust you on this one.

Also, in order to account for text direction, the direction is flipped when in RTL mode.
NOTE: The variable --mobile-font-scale is set by Frontend in
libs/mobile-app-integration/src/font-scale.tsxlibs/mobile-app-integration/src/font-scale.tsx.
It is used here to account for a bug in Safari that incorrectly calculates the width of elements
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does Safari have public bug tracking? Just wondering if there should be a link to it so that we know when we can remove the workaround.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would like to do that, but this is a long standing bug that isn't seeing any real activity on it because Webkit/Safari is in the process of rewriting zoom support for the new CSSWG standards. They have deprioritized working on any tickets that involve this bug. Many of the tickets get marked as "resolved" as a result. Let me know if you would like an alternative note to explain the bug status.

calc(
var(--perseus-multiple-choice-content-margin) +
(var(--perseus-multiple-choice-spacing) / 2)
var(--mobile-font-scale, 1) *
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool, didn't realize var had a fallback.

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.

2 participants