Skip to content

Commit 1f36af1

Browse files
committed
Fix batch Stimulus controller not removing inputs holding identifiers after unchecking all rows
1 parent ecad5b8 commit 1f36af1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

assets/controllers/batch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ export default class extends Controller {
134134
}
135135

136136
#updateIdentifierHolderInputs(identifierHolder, identifierMap) {
137-
if (identifierMap.size === 0 && this.#previousIdentifierMap) {
138-
for (const identifierName of this.#previousIdentifierMap.keys()) {
139-
const input = identifierHolder.querySelector(`input[name="${identifierName}[]"]`);
137+
for (const identifierName of this.#previousIdentifierMap?.keys() || []) {
138+
if (!identifierMap.has(identifierName)) {
139+
const inputs = identifierHolder.querySelectorAll(`input[name="${identifierName}[]"]`);
140140

141-
if (input) {
141+
for (const input of inputs) {
142142
input.remove();
143143
}
144144
}

0 commit comments

Comments
 (0)