add_group_members_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 screen in further commits.
This commit is contained in:
Shubham Padia
2024-12-11 21:53:36 +00:00
committed by Tim Abbott
parent f6bedceab3
commit c0f2697544

View File

@@ -166,14 +166,23 @@ export function set_up_handlers({
} }
$parent_container.on("keyup", pill_selector, (e) => { $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(); e.preventDefault();
callback(); callback();
} }
}); });
$parent_container.on("click", button_selector, (e) => { $parent_container.on("click", button_selector, (e) => {
e.preventDefault(); const pill_widget = get_pill_widget();
callback(); 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()!);
}
}); });
} }