invite_user_modal: Replaced email text_area with input_pill.

This makes the widget considerably more attractive, and probably a bit
more usable.

Fixes #29391.
This commit is contained in:
adnan-td
2024-03-24 00:06:45 +05:30
committed by Tim Abbott
parent 97cbf4e075
commit 87dee7a9b2
7 changed files with 152 additions and 14 deletions

View File

@@ -639,3 +639,40 @@ run_test("appendValue/clear", ({mock_template}) => {
assert.deepEqual(removed_colors, ["blue", "yellow", "red"]);
assert.equal($pill_input[0].textContent, "");
});
run_test("getCurrentText/onTextInputHook", ({mock_template}) => {
mock_template("input_pill.hbs", true, (data, html) => {
assert.equal(typeof data.display_value, "string");
return html;
});
const info = set_up();
const config = info.config;
const items = info.items;
const $pill_input = info.$pill_input;
const $container = info.$container;
const widget = input_pill.create(config);
widget.appendValue("blue,red");
assert.deepEqual(widget.items(), [items.blue, items.red]);
const onTextInputHook = () => {
assert.deepEqual(widget.items(), [items.blue, items.red]);
};
widget.onTextInputHook(onTextInputHook);
$pill_input.text("yellow");
assert.equal(widget.getCurrentText(), "yellow");
const key_handler = $container.get_on_handler("keydown", ".input");
key_handler({
key: " ",
preventDefault: noop,
});
key_handler({
key: ",",
preventDefault: noop,
});
assert.deepEqual(widget.items(), [items.blue, items.red, items.yellow]);
});