From bbbafe77a4e80536172e8126d5b141e80416c536 Mon Sep 17 00:00:00 2001 From: Cetin Sert Date: Tue, 13 Apr 2021 16:44:35 +0900 Subject: [PATCH] Fix annotation input focus trap regression in Safari `setSelectionRange(0, 0)` added in https://github.com/mozilla/pdf.js/commit/44b24fcc2936e1d75c249aa161970ab8fa83e4d2 for #12359, required only by Firefox ([bug](https://bugzilla.mozilla.org/show_bug.cgi?id=860329)), causes issues mozilla#13191, mozilla#12592 in Safari. `scrollLeft = 0` is a fix that breaks the focus trap in Safari while **keeping Firefox behavior same for #12359**. --- src/display/annotation_layer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index 84b3875cd6e6d..57370d358e806 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -668,7 +668,8 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement { if (elementData.formattedValue) { event.target.value = elementData.formattedValue; } - event.target.setSelectionRange(0, 0); + // Reset the cursor position to the start of the field (issue 12359). + event.target.scrollLeft = 0; elementData.beforeInputSelectionRange = null; };