From 776e1cee7b683da858dfa52c7f1cb7a9d5dda75b Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 3 Oct 2024 15:55:35 +0200 Subject: [PATCH 1/2] Fix bug with dictation on iOS 18+ 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. --- src/trix/controllers/level_2_input_controller.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/trix/controllers/level_2_input_controller.js b/src/trix/controllers/level_2_input_controller.js index dc4bf7dc9..65b302157 100644 --- a/src/trix/controllers/level_2_input_controller.js +++ b/src/trix/controllers/level_2_input_controller.js @@ -73,6 +73,11 @@ export default class Level2InputController extends InputController { beforeinput(event) { const handler = this.constructor.inputTypes[event.inputType] + // Handles bug with Siri dictation on iOS 18+. + if (!event.inputType) { + this.render() + } + if (handler) { this.withEvent(event, handler) this.scheduleRender() From c85546ac94735cbf70ffb31b2aef1c327c9e8cb7 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Fri, 4 Oct 2024 08:57:45 +0200 Subject: [PATCH 2/2] v2.1.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 65ed64cda..52b3d3cd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "trix", - "version": "2.1.5", + "version": "2.1.6", "description": "A rich text editor for everyday writing", "main": "dist/trix.umd.min.js", "module": "dist/trix.esm.min.js",