From 2f7188a724b6f15585284e706bf51134bbf27e2d Mon Sep 17 00:00:00 2001 From: tabaina Date: Wed, 6 May 2026 00:59:33 +0300 Subject: [PATCH] fixed caret jumping on fast typing in masked text input commit_hash:d5b27de9c760bc32766d292e75153671946e029a --- ...TextInputBlock+UIViewRenderableBlock.swift | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/client/ios/LayoutKit/LayoutKit/UI/Blocks/TextInputBlock+UIViewRenderableBlock.swift b/client/ios/LayoutKit/LayoutKit/UI/Blocks/TextInputBlock+UIViewRenderableBlock.swift index cda0288e2..3d70dfccc 100644 --- a/client/ios/LayoutKit/LayoutKit/UI/Blocks/TextInputBlock+UIViewRenderableBlock.swift +++ b/client/ios/LayoutKit/LayoutKit/UI/Blocks/TextInputBlock+UIViewRenderableBlock.swift @@ -477,17 +477,15 @@ private final class TextInputBlockView: BlockView, VisibleBoundsTrackingLeaf { ) maskedViewModel?.$cursorPosition.currentAndNewValues.addObserver { [weak self] range in guard let self, let range else { return } - DispatchQueue.main.async { - self.multiLineInput.selectedRange = range - if let textFieldPosition = self.singleLineInput.position( - from: self.singleLineInput.beginningOfDocument, - offset: range.location - ), self.singleLineInput.selectedTextRange?.start != textFieldPosition { - self.singleLineInput.selectedTextRange = self.singleLineInput.textRange( - from: textFieldPosition, - to: textFieldPosition - ) - } + multiLineInput.selectedRange = range + if let textFieldPosition = singleLineInput.position( + from: singleLineInput.beginningOfDocument, + offset: range.location + ), singleLineInput.selectedTextRange?.start != textFieldPosition { + singleLineInput.selectedTextRange = singleLineInput.textRange( + from: textFieldPosition, + to: textFieldPosition + ) } }.dispose(in: disposePool) maskedViewModel?.$rawText.currentAndNewValues.addObserver { [weak self] input in @@ -498,11 +496,9 @@ private final class TextInputBlockView: BlockView, VisibleBoundsTrackingLeaf { maskedViewModel?.$formattedText.currentAndNewValues .addObserver { [weak self] input in guard let self else { return } - DispatchQueue.main.async { - self.setTextData(input) - self.textValue.value = input - self.updateHintVisibility() - } + setTextData(input) + textValue.value = input + updateHintVisibility() }.dispose(in: disposePool) }