Merge pull request #12052 from dacook/hotkeys

Hotkey fix
This commit is contained in:
Konrad
2024-01-24 23:34:50 +01:00
committed by GitHub
2 changed files with 5 additions and 5 deletions

View File

@@ -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,

View File

@@ -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();
});