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 bug with dictation on iOS 18+ #1191

Merged
merged 2 commits into from
Oct 4, 2024
Merged

Fix bug with dictation on iOS 18+ #1191

merged 2 commits into from
Oct 4, 2024

Conversation

jorgemanrubia
Copy link
Member

@jorgemanrubia jorgemanrubia commented Oct 3, 2024

Fixes a bug where dictating in iOS 18 can result in losing or garbling existing content.

Dictation on iOS does not trigger composition events (https://bugs.webkit.org/show_bug.cgi?id=261764). Instead, it triggers beforeinput events with insertText. During the dictation phase, it keeps the range anchored to the cursor, and iOS may modify past text as new text adds context.

Once dictation is stopped, it starts sending insertText events with word fragments. When a past fragment is altered, iOS sends a beforeinput event where inputType is null. In this case, the patch makes Trix perform a synchronous render operation to set the editor to the correct state. Otherwise, scheduled render requests can process invalid ranges and mess with the editor contents.

karma.conf.js Outdated
base: "SauceLabs",
browserName: "safari",
platform: "macOS 10.13",
version: "12.1"
version: "16.4"
Copy link
Member Author

Choose a reason for hiding this comment

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

@seanpdoyle I got a CI error due to attachInternals failing in old Safari. I wondered why it passed the other day in your PR. It seems it didn't run the sauce tests there?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's surprising.

The merge commit failed against main, but passed (or did not run) on the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

CI reads the SAUCE-prefixed environment variables from GitHub action secrets, sets them as environment variables, then reads those values as part of the Karma setup.

However,

With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository.

That means unless there is an alternative solution, pull requests from the community won't run in Sauce Labs managed environments. That seems like a risk to the project's backwards compatibility goals.

Dictation on iOS does not trigger composition events (https://bugs.webkit.org/show_bug.cgi?id=261764). Instead, it
triggers `beforeinput` events with `insertText`. During the dictation phase, it keeps the range anchored to the
cursor, and iOS may modify past text as new text adds context.

Once dictation is stopped, it starts sending `insertText` events with word fragments. When a past fragment is
altered, iOS sends a `beforeinput` event where `inputType` is null. In this case, perform a synchronous render
operation to set the editor to the correct state. Otherwise, scheduled render requests can process invalid
ranges and mess with the editor contents.
@jorgemanrubia jorgemanrubia merged commit c85546a into main Oct 4, 2024
3 checks passed
@jorgemanrubia jorgemanrubia deleted the ios-dictation-bug branch October 4, 2024 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants