Skip to content

Commit 6777299

Browse files
committed
Add order change checks to prevent unnecessary reorder callbacks in Configurations and Presets components
1 parent f9bb05b commit 6777299

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎packages/ui/src/components/editor/panel/Configurations/Configurations.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,15 @@ export const Configurations: React.FC<Configurations.Props> = (props) => {
121121
list={props.configurations}
122122
setList={(new_state) => {
123123
if (props.on_reorder) {
124-
props.on_reorder(new_state)
124+
const has_order_changed =
125+
new_state.length != props.configurations.length ||
126+
new_state.some(
127+
(item, index) => item.id != props.configurations[index].id
128+
)
129+
130+
if (has_order_changed) {
131+
props.on_reorder(new_state)
132+
}
125133
}
126134
}}
127135
animation={150}

‎packages/ui/src/components/editor/panel/Presets/Presets.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,16 @@ export const Presets: React.FC<Presets.Props> = (props) => {
249249
<ReactSortable
250250
list={sortable_list}
251251
setList={(new_state) => {
252+
const has_order_changed =
253+
new_state.length != sortable_list.length ||
254+
new_state.some(
255+
(item, index) => item.id != sortable_list[index].id
256+
)
257+
258+
if (!has_order_changed) {
259+
return
260+
}
261+
252262
// Handle normal preset/group reordering
253263
const new_visible_presets = new_state.map(
254264
({ id, ...preset }) => preset

0 commit comments

Comments
 (0)