@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.

Fix an async display issue for tokenizer/typeahead results

Summary:
Ref T4420. After the changes to the tokenizer, I sometimes do this:

- Type something like "diff" into a project typeahead.
- Select "differential".
- A fraction of a second later, the typeahead pops back open.

This is because I selected the result from a partial query (like "diff" running against the "di" results) and then the full results of the "diff" query came back to the browser.

Instead, when showing results, require that the current state match the state that the results are for: don't show "dog" results if the tokenizer now reads "cat", for whatever reason.

Test Plan: Added a 1s delay to results, typed "a", then typed "m" and selected a result in less than a second. Prior to the patch, the tokenizer would pop back open with "am" results afterward. Now, it doesn't.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T4420

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

+50 -32
+27 -27
resources/celerity/map.php
··· 14 14 'differential.pkg.js' => '322ea941', 15 15 'diffusion.pkg.css' => '3783278d', 16 16 'diffusion.pkg.js' => '7b51e80a', 17 - 'javelin.pkg.js' => 'c7ef4e11', 17 + 'javelin.pkg.js' => '133881a7', 18 18 'maniphest.pkg.css' => 'f1887d71', 19 19 'maniphest.pkg.js' => '1e8f11af', 20 20 'rsrc/css/aphront/aphront-bars.css' => '231ac33c', ··· 208 208 'rsrc/externals/javelin/lib/__tests__/behavior.js' => 'c1d75ee6', 209 209 'rsrc/externals/javelin/lib/behavior.js' => '8a3ed18b', 210 210 'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => '1c1a6cdf', 211 - 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => 'd99e27f7', 211 + 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => 'caab854b', 212 212 'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => '5f850b5c', 213 - 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => 'dbd9cd11', 213 + 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '0136cec1', 214 214 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js' => '7383383f', 215 215 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadPreloadedSource.js' => 'e9b95df3', 216 - 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js' => '5e18d309', 216 + 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js' => '62e18640', 217 217 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadStaticSource.js' => 'c2b8bf64', 218 218 'rsrc/externals/raphael/g.raphael.js' => '40dde778', 219 219 'rsrc/externals/raphael/g.raphael.line.js' => '40da039e', ··· 642 642 'javelin-resource' => '356de121', 643 643 'javelin-stratcom' => 'c293f7b9', 644 644 'javelin-tokenizer' => '1c1a6cdf', 645 - 'javelin-typeahead' => 'd99e27f7', 646 - 'javelin-typeahead-composite-source' => 'dbd9cd11', 645 + 'javelin-typeahead' => 'caab854b', 646 + 'javelin-typeahead-composite-source' => '0136cec1', 647 647 'javelin-typeahead-normalizer' => '5f850b5c', 648 648 'javelin-typeahead-ondemand-source' => '7383383f', 649 649 'javelin-typeahead-preloaded-source' => 'e9b95df3', 650 - 'javelin-typeahead-source' => '5e18d309', 650 + 'javelin-typeahead-source' => '62e18640', 651 651 'javelin-typeahead-static-source' => 'c2b8bf64', 652 652 'javelin-uri' => 'd9a9b862', 653 653 'javelin-util' => '7501647b', ··· 799 799 ), 800 800 'requires' => 801 801 array( 802 + '0136cec1' => 803 + array( 804 + 0 => 'javelin-install', 805 + 1 => 'javelin-typeahead-source', 806 + 2 => 'javelin-util', 807 + ), 802 808 '029a133d' => 803 809 array( 804 810 0 => 'aphront-dialog-view-css', ··· 1162 1168 2 => 'javelin-dom', 1163 1169 3 => 'javelin-stratcom', 1164 1170 4 => 'javelin-vector', 1165 - ), 1166 - '5e18d309' => 1167 - array( 1168 - 0 => 'javelin-install', 1169 - 1 => 'javelin-util', 1170 - 2 => 'javelin-dom', 1171 - 3 => 'javelin-typeahead-normalizer', 1172 1171 ), 1173 1172 '5f004630' => 1174 1173 array( ··· 1191 1190 2 => 'javelin-util', 1192 1191 3 => 'phabricator-shaped-request', 1193 1192 ), 1193 + '62e18640' => 1194 + array( 1195 + 0 => 'javelin-install', 1196 + 1 => 'javelin-util', 1197 + 2 => 'javelin-dom', 1198 + 3 => 'javelin-typeahead-normalizer', 1199 + ), 1194 1200 '63f9ad59' => 1195 1201 array( 1196 1202 0 => 'javelin-install', ··· 1677 1683 0 => 'javelin-install', 1678 1684 1 => 'javelin-util', 1679 1685 ), 1686 + 'caab854b' => 1687 + array( 1688 + 0 => 'javelin-install', 1689 + 1 => 'javelin-dom', 1690 + 2 => 'javelin-vector', 1691 + 3 => 'javelin-util', 1692 + ), 1680 1693 'cd9e7094' => 1681 1694 array( 1682 1695 0 => 'javelin-behavior', ··· 1760 1773 7 => 'phabricator-dropdown-menu', 1761 1774 8 => 'phabricator-menu-item', 1762 1775 ), 1763 - 'd99e27f7' => 1764 - array( 1765 - 0 => 'javelin-install', 1766 - 1 => 'javelin-dom', 1767 - 2 => 'javelin-vector', 1768 - 3 => 'javelin-util', 1769 - ), 1770 1776 'd9a9b862' => 1771 1777 array( 1772 1778 0 => 'javelin-install', ··· 1784 1790 array( 1785 1791 0 => 'javelin-behavior', 1786 1792 1 => 'javelin-dom', 1787 - ), 1788 - 'dbd9cd11' => 1789 - array( 1790 - 0 => 'javelin-install', 1791 - 1 => 'javelin-typeahead-source', 1792 - 2 => 'javelin-util', 1793 1793 ), 1794 1794 'dd7e8ef5' => 1795 1795 array(
+20 -2
webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js
··· 230 230 * in response to events from the datasource you have configured. 231 231 * 232 232 * @task control 233 - * @param list List of ##<a />## tags to show as suggestions/results. 233 + * @param list List of ##<a />## tags to show as suggestions/results. 234 + * @param string The query this result list corresponds to. 234 235 * @return void 235 236 */ 236 - showResults : function(results) { 237 + showResults : function(results, value) { 238 + if (value != this._value) { 239 + // This result list is for an old query, and no longer represents 240 + // the input state of the typeahead. 241 + 242 + // For example, the user may have typed "dog", and then they delete 243 + // their query and type "cat", and then the "dog" results arrive from 244 + // the source. 245 + 246 + // Another case is that the user made a selection in a tokenizer, 247 + // and then results returned. However, the typeahead is now empty, and 248 + // we don't want to pop it back open. 249 + 250 + // In all cases, just throw these results away. They are no longer 251 + // relevant. 252 + return; 253 + } 254 + 237 255 var obj = {show: results}; 238 256 var e = this.invoke('show', obj); 239 257
+2 -2
webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js
··· 50 50 } 51 51 }, 52 52 53 - childResultsReady : function(nodes) { 53 + childResultsReady : function(nodes, value) { 54 54 this.results = this.mergeResults(this.results || [], nodes); 55 - this.invoke('resultsready', this.results); 55 + this.invoke('resultsready', this.results, value); 56 56 }, 57 57 58 58 childComplete : function() {
+1 -1
webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js
··· 292 292 this.filterAndSortHits(value, hits); 293 293 294 294 var nodes = this.renderNodes(value, hits); 295 - this.invoke('resultsready', nodes); 295 + this.invoke('resultsready', nodes, value); 296 296 if (!partial) { 297 297 this.invoke('complete'); 298 298 }