@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Retain focused node when redrawing tokenizer/typeahead results

Summary:
Ref T4420. Fixes T5473. Currently, when typeahead results get redrawn, you can lose your cursor position. A simple way to reproduce this is type "dif", select "Differential" using the arrow keys, then type "f". The selection will be lost.

Instead: store the old selection, then look for an item with the same name in the new set and select it. In effect, this preserves any focus selection.

Test Plan:
- Typed "dif".
- Typed "down arrow key" to select "Differential".
- Typed "f".
- "Differential" remained selected.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5473, T4420

Differential Revision: https://secure.phabricator.com/D9900

+30 -9
+9 -9
resources/celerity/map.php
··· 8 8 return array( 9 9 'names' => array( 10 10 'core.pkg.css' => 'c2c68e64', 11 - 'core.pkg.js' => '0095fb2c', 11 + 'core.pkg.js' => 'dc4959a8', 12 12 'darkconsole.pkg.js' => 'df001cab', 13 13 'differential.pkg.css' => '4a93db37', 14 14 'differential.pkg.js' => '7528cfc9', ··· 212 212 'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783', 213 213 'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a', 214 214 'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => 'a5b67173', 215 - 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '61f72a3d', 215 + 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => 'e614d22b', 216 216 'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'aa93c7b0', 217 217 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd', 218 218 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js' => '8b3fd187', ··· 683 683 'javelin-router' => '29274e2b', 684 684 'javelin-stratcom' => '8b0ad945', 685 685 'javelin-tokenizer' => 'a5b67173', 686 - 'javelin-typeahead' => '61f72a3d', 686 + 'javelin-typeahead' => 'e614d22b', 687 687 'javelin-typeahead-composite-source' => '503e17fd', 688 688 'javelin-typeahead-normalizer' => 'aa93c7b0', 689 689 'javelin-typeahead-ondemand-source' => '8b3fd187', ··· 1245 1245 0 => 'javelin-magical-init', 1246 1246 1 => 'javelin-util', 1247 1247 ), 1248 - '61f72a3d' => array( 1249 - 0 => 'javelin-install', 1250 - 1 => 'javelin-dom', 1251 - 2 => 'javelin-vector', 1252 - 3 => 'javelin-util', 1253 - ), 1254 1248 '6453c869' => array( 1255 1249 0 => 'javelin-install', 1256 1250 1 => 'javelin-dom', ··· 1834 1828 0 => 'javelin-install', 1835 1829 1 => 'javelin-dom', 1836 1830 2 => 'javelin-view-visitor', 1831 + 3 => 'javelin-util', 1832 + ), 1833 + 'e614d22b' => array( 1834 + 0 => 'javelin-install', 1835 + 1 => 'javelin-dom', 1836 + 2 => 'javelin-vector', 1837 1837 3 => 'javelin-util', 1838 1838 ), 1839 1839 'e9581f08' => array(
+21
webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js
··· 241 241 var obj = {show: results}; 242 242 var e = this.invoke('show', obj); 243 243 244 + // If the user has an element focused, store the value before we redraw. 245 + // After we redraw, try to select the same element if it still exists in 246 + // the list. This prevents redraws from disrupting keyboard element 247 + // selection. 248 + var old_focus = null; 249 + if (this._focus >= 0 && this._display[this._focus]) { 250 + old_focus = this._display[this._focus].name; 251 + } 252 + 244 253 // Note that the results list may have been update by the "show" event 245 254 // listener. Non-result node (e.g. divider or label) may have been 246 255 // inserted. ··· 256 265 this._hardpoint.appendChild(this._root); 257 266 } 258 267 JX.DOM.show(this._root); 268 + 269 + // If we had a node focused before, look for a node with the same value 270 + // and focus it. 271 + if (old_focus !== null) { 272 + for (var ii = 0; ii < this._display.length; ii++) { 273 + if (this._display[ii].name == old_focus) { 274 + this._focus = ii; 275 + this._drawFocus(); 276 + break; 277 + } 278 + } 279 + } 259 280 } else { 260 281 this.hide(); 261 282 JX.DOM.setContent(this._root, null);