mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
@@ -5,7 +5,6 @@ export default class extends Controller {
|
||||
static values = { options: Object, placeholder: String };
|
||||
|
||||
connect(options = {}) {
|
||||
console.log(this.element, this.placeholderValue);
|
||||
this.control = new TomSelect(this.element, {
|
||||
maxItems: 1,
|
||||
maxOptions: null,
|
||||
|
||||
@@ -13,8 +13,9 @@ hotkeys.filter = function (event) {
|
||||
hotkeys("ctrl+enter, command+enter", function (event, handler) {
|
||||
const form = event.target.form;
|
||||
|
||||
// If element has a non-angular form
|
||||
if (form && !form.classList.contains("ng")) {
|
||||
form.submit();
|
||||
}
|
||||
// Simulate a click on the first available submit button. This seems to be the most robust option,
|
||||
// ensuring that event handlers are handled first (eg for StimulusReflex). If there's no submit
|
||||
// button, nothing happens (eg for Angular forms).
|
||||
const submit = form && form.querySelector('input[type="submit"], button[type="submit"]');
|
||||
submit && submit.click();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user