Skip to content

Commit d5c97a5

Browse files
committed
Add keydown.enter action to new row
A convenient shortcut to "Apply" changes by pressing Enter while filling in data for new option values.
1 parent c2c4443 commit d5c97a5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

admin/app/components/solidus_admin/option_types/edit/option_values_table/row/component.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ export default class extends Controller {
1010
remove() {
1111
this.element.remove();
1212
}
13+
14+
applyOnEnter(event) {
15+
const submitter = event.target.form.elements.apply
16+
if (submitter) {
17+
event.preventDefault();
18+
event.target.form.requestSubmit(submitter);
19+
}
20+
}
1321
}

admin/app/components/solidus_admin/option_types/edit/option_values_table/row/component.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def columns
4545
"aria-label": true,
4646
form: @form_id,
4747
"data-#{stimulus_id}-target": "focusable",
48+
"data-action": "keydown.enter->#{stimulus_id}#applyOnEnter",
4849
)
4950
end
5051
},
@@ -57,6 +58,7 @@ def columns
5758
class: "required",
5859
"aria-label": true,
5960
form: @form_id,
61+
"data-action": "keydown.enter->#{stimulus_id}#applyOnEnter",
6062
)
6163
end
6264
}

0 commit comments

Comments
 (0)