Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

input pills: Focus input after removing a pill with x button.

evykassirer23e736385025
diff --git a/web/src/input_pill.ts b/web/src/input_pill.ts
index 3ffe2928f2d..53f08d4279f 100644
--- a/web/src/input_pill.ts
+++ b/web/src/input_pill.ts
@@ -528,7 +528,7 @@ export function create<T>(opts: InputPillCreateOptions<T>): InputPillContainer<T
});
// when the "×" is clicked on a pill, it should delete that pill and then
- // select the next pill (or input).
+ // select the input field.
store.$parent.on("click", ".exit", function (this: HTMLElement, e) {
const $user_pill_container = $(this).parents(".user-pill-container");
if ($user_pill_container.length) {
@@ -540,17 +540,15 @@ export function create<T>(opts: InputPillCreateOptions<T>): InputPillContainer<T
const user_id = $(this).closest(".pill").attr("data-user-id");
assert(user_id !== undefined);
funcs.removeUserPill($user_pill_container[0]!, Number.parseInt(user_id, 10));
- return;
+ } else {
+ e.stopPropagation();
+ const $pill = $(this).closest(".pill");
+ funcs.removePill($pill[0]!);
}
- e.stopPropagation();
- const $pill = $(this).closest(".pill");
- const $next = $pill.next();
-
- funcs.removePill($pill[0]!);
// Since removing a pill moves the $input, typeahead needs to refresh
// to appear at the correct position.
store.$input.trigger(new $.Event("typeahead.refreshPosition"));
- $next.trigger("focus");
+ store.$input.trigger("focus");
});
store.$parent.on("click", function (e) {
diff --git a/web/tests/input_pill.test.js b/web/tests/input_pill.test.js
index ab2e85d8b7f..6cf256c466a 100644
--- a/web/tests/input_pill.test.js
+++ b/web/tests/input_pill.test.js
@@ -508,18 +508,7 @@ run_test("exit button on pill", ({mock_template}) => {
pill.$element.remove = noop;
}
- let next_pill_focused = false;
-
- const $next_pill_stub = {
- trigger(type) {
- if (type === "focus") {
- next_pill_focused = true;
- }
- },
- };
-
const $curr_pill_stub = {
- next: () => $next_pill_stub,
[0]: "<pill-stub BLUE>",
};
@@ -542,8 +531,6 @@ run_test("exit button on pill", ({mock_template}) => {
exit_click_handler.call(exit_button_stub, e);
- assert.ok(next_pill_focused);
-
assert.deepEqual(widget.items(), [items.red]);
});