Skip to content

Commit 246ccc3

Browse files
chaimanntvdeyen
authored andcommitted
Fix rewriting previous mode
We don't want to rewrite previousMode if it is already set, otherwise we may end up in "batch" mode forever. So better to use `modeValueChanged` hook and save previous mode value there.
1 parent 8ae171e commit 246ccc3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

admin/app/components/solidus_admin/ui/table/component.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export default class extends Controller {
3232
}
3333

3434
// Determine if sortable should be enabled
35-
modeValueChanged() {
35+
modeValueChanged(_current, previous) {
36+
this.previousMode = previous;
37+
3638
const shouldSetSortable = this.sortableValue && this.modeValue !== "batch" && this.modeValue !== "search"
3739

3840
if (shouldSetSortable) {
@@ -69,8 +71,7 @@ export default class extends Controller {
6971

7072
selectRow(event) {
7173
if (this.checkboxTargets.some((checkbox) => checkbox.checked)) {
72-
this.previousMode = this.modeValue;
73-
this.modeValue = "batch"
74+
this.modeValue = "batch";
7475
} else {
7576
this.modeValue = this.previousMode;
7677
}
@@ -80,8 +81,7 @@ export default class extends Controller {
8081

8182
selectAllRows(event) {
8283
if (event.target.checked) {
83-
this.previousMode = this.modeValue;
84-
this.modeValue = "batch"
84+
this.modeValue = "batch";
8585
} else {
8686
this.modeValue = this.previousMode;
8787
}

0 commit comments

Comments
 (0)