add_subscribers_pill: Add button should show error on pending text.

This commit only changes the behaviour for edit screen of this setting.
We'll tackle the create screens in further commits.
This commit is contained in:
Shubham Padia
2024-12-11 07:42:49 +00:00
committed by Tim Abbott
parent 0ee2543a49
commit f6bedceab3

View File

@@ -256,14 +256,23 @@ export function set_up_handlers({
}
$parent_container.on("keyup", pill_selector, (e) => {
if (keydown_util.is_enter_event(e)) {
const pill_widget = get_pill_widget();
if (!pill_widget.is_pending() && keydown_util.is_enter_event(e)) {
e.preventDefault();
callback();
}
});
$parent_container.on("click", button_selector, (e) => {
e.preventDefault();
callback();
const pill_widget = get_pill_widget();
if (!pill_widget.is_pending()) {
e.preventDefault();
callback();
} else {
// We are not appending any value here, but instead this is
// a proxy to invoke the error state for a pill widget
// that would usually get triggered on pressing enter.
pill_widget.appendValue(pill_widget.getCurrentText()!);
}
});
}