▾ modified flutter/src/frq/hiccup.cljd +13 -4 Viewed
@@ -155,11 +155,20 @@ 155 155 (let [c (m/TextEditingController .text (or text ""))] 156 156 (swap! controllers assoc k c) 157 157 c))] 158 - ;; Only when it differs, and never while it would move the caret: the cell 159 - ;; is the authority for what the entry says, but the person typing is the 160 - ;; authority for where they are in it. 158 + ;; Only when it differs: the cell is the authority for what the entry 159 + ;; says, but the person typing is the authority for where they are in it, 160 + ;; and every keystroke would otherwise be written back over itself. 161 + ;; 162 + ;; The whole value and not just `.text`, which is the bug Tab completion 163 + ;; found. Assigning `.text` leaves the selection at offset -1, and Flutter 164 + ;; draws that as the entire field selected — so completing a nick handed 165 + ;; back `nandi.uk: ` highlighted, and the next character typed would have 166 + ;; replaced it. The caret belongs after what was just put there. 161 167 (when (and text (not= text (.-text c))) 162 - (set! (.-text c) text)) 168 + (set! (.-value c) 169 + (m/TextEditingValue 170 + .text text 171 + .selection (m/TextSelection.collapsed .offset (count text))))) 163 172 c)) 164 173 165 174 ;; ------------------------------------------------------------------ props
@@ -155,11 +155,20 @@ 155 (let [c (m/TextEditingController .text (or text ""))] 155 (let [c (m/TextEditingController .text (or text ""))] 156 (swap! controllers assoc k c) 156 (swap! controllers assoc k c) 157 c))] 157 c))] 158 - ;; Only when it differs, and never while it would move the caret: the cell 158 + ;; Only when it differs: the cell is the authority for what the entry 159 - ;; is the authority for what the entry says, but the person typing is the 159 + ;; says, but the person typing is the authority for where they are in it, 160 - ;; authority for where they are in it. 160 + ;; and every keystroke would otherwise be written back over itself. 161 + ;; 162 + ;; The whole value and not just `.text`, which is the bug Tab completion 163 + ;; found. Assigning `.text` leaves the selection at offset -1, and Flutter 164 + ;; draws that as the entire field selected — so completing a nick handed 165 + ;; back `nandi.uk: ` highlighted, and the next character typed would have 166 + ;; replaced it. The caret belongs after what was just put there. 161 (when (and text (not= text (.-text c))) 167 (when (and text (not= text (.-text c))) 162 - (set! (.-text c) text)) 168 + (set! (.-value c) 169 + (m/TextEditingValue 170 + .text text 171 + .selection (m/TextSelection.collapsed .offset (count text))))) 163 c)) 172 c)) 164 173 165 ;; ------------------------------------------------------------------ props 174 ;; ------------------------------------------------------------------ props