mirror of https://github.com/zulip/zulip.git
06b1aece31
Before this change, if you hit ESC, then hotkey code would call search.clear_search, which would call narrow.deactivate(), which would then use `$('#search_query')` to clear a value, but then let search.clear_search blur the input and disable the exit button. It was all confusing. Things are a bit more organized now. Now the code works like this: hotkey.process_escape_key Just call narrow.deactivate. $('#search_exit').on('click', ...): Just call narrow.deactivate. narrow.deactivate: Just call search.clear_search_form search.clear_search_form: Just do simple jquery stuff. Don't change the entire user's narrow, not even indirectly! There's still a two-way interaction between the narrow.js module and the search.js module, but in each direction it's a one-liner. The guiding principle here is that we only want one top-level API, which is narrow.deactivate, and that does the whole "kitchen sink" of clearing searches, closing popovers, switching in views, etc. And then all the functions it calls out to tend to have much smaller jobs to do. This commit can mostly be considered a refactoring, but the order of operations changes slightly. Basically, as soon as you hit ESC or click on the search "X", we clear the search widget. Most users won't notice any difference, because we don't have to hit the server to populate the home view. And it's arguably an improvement to give more immediate feedback. |
||
---|---|---|
.. | ||
casper_lib | ||
casper_tests | ||
node_tests | ||
zjsunit | ||
.eslintrc.json | ||
run-casper |