Skip to content

[lexical-playground] Bug Fix: Fix equation rendering in Safari#7362

Merged
etrepum merged 2 commits intofacebook:mainfrom
bgwebagency:fix/safari-equation-empty-images
Mar 23, 2025
Merged

[lexical-playground] Bug Fix: Fix equation rendering in Safari#7362
etrepum merged 2 commits intofacebook:mainfrom
bgwebagency:fix/safari-equation-empty-images

Conversation

@kirandash
Copy link
Copy Markdown
Contributor

Description

Current Behavior:
The KatexRenderer component uses empty image tags with src="#" around equations to prevent Android composition issues. However, this causes Safari to display question marks around the equations, creating an undesirable visual artifact.

Changes being added:
This PR replaces the empty image tags' src attribute with a transparent 1x1 pixel GIF data URL and adds width/height=0 attributes. This maintains the Android composition prevention functionality while fixing the Safari display issue. The images will now be completely invisible across all browsers.

Closes #6824

Test plan

Before

When adding an equation in Safari:

  • Question marks appear on either side of the equation
  • The issue is specific to Safari browser
    image

After

  • No question marks visible around equations in Safari
  • Equations render cleanly without any visual artifacts
  • Android composition prevention still works as expected
  • No visual changes in other browsers (Chrome, Firefox, etc.)

image

The empty images around equations in KatexRenderer were using '#' as src,
which caused Safari to display question marks. This change replaces the
src with a transparent 1x1 pixel GIF data URL and adds width/height=0
to ensure the images remain invisible while maintaining the Android
composition prevention functionality.

Fixes facebook#6824
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 23, 2025 6:34am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 23, 2025 6:34am

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 23, 2025
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Mar 23, 2025
@kirandash kirandash marked this pull request as draft March 23, 2025 06:14
@kirandash kirandash changed the title [lexical-playground] Bug Fix: Fix equation rendering in Safari [WIP][lexical-playground] Bug Fix: Fix equation rendering in Safari Mar 23, 2025
Update test snapshots in Markdown and regression tests to match the new
empty image implementation that uses transparent data URLs and zero
dimensions. This aligns the test expectations with the Safari
compatibility fix.

- Update Markdown.spec.mjs equation HTML snapshot
- Update regression test 6974 HTML snapshots
- Maintain existing test logic and functionality

Relates to facebook#6824
@kirandash kirandash changed the title [WIP][lexical-playground] Bug Fix: Fix equation rendering in Safari [lexical-playground] Bug Fix: Fix equation rendering in Safari Mar 23, 2025
@kirandash kirandash marked this pull request as ready for review March 23, 2025 07:43
@etrepum etrepum added this pull request to the merge queue Mar 23, 2025
Merged via the queue into facebook:main with commit 6a5a6c8 Mar 23, 2025
39 checks passed
GermanJablo added a commit to payloadcms/payload that referenced this pull request Sep 3, 2025
Fixes #13386

Below I write a clarification to copy and paste into the release note,
based on our latest upgrade of Lexical [in
v3.29.0](https://github.com/payloadcms/payload/releases/tag/v3.29.0).

## Important
This release upgrades the lexical dependency from 0.28.0 to 0.34.0.

If you installed lexical manually, update it to 0.34.0. Installing
lexical manually is not recommended, as it may break between updates,
and our re-exported versions should be used. See the [yellow banner
box](https://payloadcms.com/docs/rich-text/custom-features) for details.

If you still encounter richtext-lexical errors, do the following, in
this order:

- Delete node_modules
- Delete your lockfile (e.g. pnpm-lock.json)
- Reinstall your dependencies (e.g. pnpm install)

### Lexical Breaking Changes

The following Lexical releases describe breaking changes. We recommend
reading them if you're using Lexical APIs directly
(`@payloadcms/richtext-lexical/lexical/*`).

- [v.0.33.0](https://github.com/facebook/lexical/releases/tag/v0.33.0)
- [v.0.30.0](https://github.com/facebook/lexical/releases/tag/v0.30.0)
- [v.0.29.0](https://github.com/facebook/lexical/releases/tag/v0.29.0)

___

TODO:
- [x] facebook/lexical#7719
- [x] facebook/lexical#7362
- [x] facebook/lexical#7707
- [x] facebook/lexical#7388
- [x] facebook/lexical#7357
- [x] facebook/lexical#7352
- [x] facebook/lexical#7472
- [x] facebook/lexical#7556
- [x] facebook/lexical#7417
- [x] facebook/lexical#1036
- [x] facebook/lexical#7509
- [x] facebook/lexical#7693
- [x] facebook/lexical#7408
- [x] facebook/lexical#7450
- [x] facebook/lexical#7415
- [x] facebook/lexical#7368
- [x] facebook/lexical#7372
- [x] facebook/lexical#7572
- [x] facebook/lexical#7558
- [x] facebook/lexical#7613
- [x] facebook/lexical#7405
- [x] facebook/lexical#7420
- [x] facebook/lexical#7662

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1211202581885926
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: empty images around equations render as question marks on Safari

3 participants