@klyftig/mobile-ui 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -28,6 +28,13 @@ interface GlassInputProps {
|
|
|
28
28
|
selectTextOnFocus?: boolean;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// When a single-line input is not focused, anchor the selection to the start so
|
|
32
|
+
// iOS/Android scroll a value longer than the field to reveal its BEGINNING
|
|
33
|
+
// ("Carrot - Cream Sauce…") instead of its tail ("…Sauce - pistachio nuts").
|
|
34
|
+
// Only applied while unfocused — during editing the selection stays uncontrolled
|
|
35
|
+
// so the caret follows taps and typing normally.
|
|
36
|
+
const SELECTION_START = { start: 0, end: 0 } as const;
|
|
37
|
+
|
|
31
38
|
const GlassInputComponent: React.FC<GlassInputProps> = ({
|
|
32
39
|
label,
|
|
33
40
|
value,
|
|
@@ -98,6 +105,7 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
|
|
|
98
105
|
onFocus={handleFocus}
|
|
99
106
|
onBlur={handleBlur}
|
|
100
107
|
selectTextOnFocus={selectTextOnFocus}
|
|
108
|
+
selection={!isFocused && !multiline ? SELECTION_START : undefined}
|
|
101
109
|
multiline={multiline}
|
|
102
110
|
numberOfLines={numberOfLines}
|
|
103
111
|
textAlignVertical={multiline ? 'top' : undefined}
|