Skip to content

Commit f6d919c

Browse files
chaimanntvdeyen
authored andcommitted
Improve transitioning from batch mode
Having "search" mode as default transition from "batch" mode was not ideal because if a table is sortable and does not have a search field, leaving "batch" mode would turn on "search" mode, mode which disables sorting. Instead, let's just remember which mode we were on before going into "batch", and then restore it.
1 parent 2aca466 commit f6d919c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,21 @@ export default class extends Controller {
6969

7070
selectRow(event) {
7171
if (this.checkboxTargets.some((checkbox) => checkbox.checked)) {
72+
this.previousMode = this.modeValue;
7273
this.modeValue = "batch"
73-
} else if (this.hasSearchFieldTarget && this.searchFieldTarget.value !== "") {
74-
this.modeValue = "search"
75-
} else if (this.hasScopesToolbarTarget) {
76-
this.modeValue = "scopes"
7774
} else {
78-
this.modeValue = "search"
75+
this.modeValue = this.previousMode;
7976
}
8077

8178
this.render()
8279
}
8380

8481
selectAllRows(event) {
8582
if (event.target.checked) {
83+
this.previousMode = this.modeValue;
8684
this.modeValue = "batch"
87-
} else if (this.hasSearchFieldTarget && this.searchFieldTarget.value !== "") {
88-
this.modeValue = "search"
89-
} else if (this.hasScopesToolbarTarget) {
90-
this.modeValue = "scopes"
9185
} else {
92-
this.modeValue = "search"
86+
this.modeValue = this.previousMode;
9387
}
9488

9589
this.checkboxTargets.forEach((checkbox) => (checkbox.checked = event.target.checked))

0 commit comments

Comments
 (0)