Skip to content

Commit b7ecced

Browse files
committed
Commit: Update selection logic for Row components in main.js
1 parent 31f6203 commit b7ecced

File tree

1 file changed

+17
-15
lines changed
  • frameworks/keyed/million/src

1 file changed

+17
-15
lines changed

frameworks/keyed/million/src/main.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,31 +129,33 @@ const swapRows = () => {
129129
let prevBlock;
130130

131131
const select = (id) => {
132+
if (prevBlock) {
133+
if (prevBlock.props.id === id) return;
134+
const { id: prevId, label } = prevBlock.props;
135+
const row = Row(
136+
{
137+
id: prevId,
138+
label,
139+
className: '',
140+
},
141+
String(id)
142+
);
143+
row.memo = [label, false];
144+
prevBlock.patch(row);
145+
}
132146
const block = main.children.find((block) => block.props.id === id);
147+
const { label } = block.props;
133148
const row = Row(
134149
{
135150
id,
136-
label: block.props.label,
151+
label,
137152
className: 'danger',
138153
},
139154
String(id)
140155
);
141-
row.memo = [block.props.label, true];
156+
row.memo = [label, true];
142157
block.patch(row);
143158

144-
if (prevBlock) {
145-
const row = Row(
146-
{
147-
id: prevBlock.props.id,
148-
label: prevBlock.props.label,
149-
className: '',
150-
},
151-
String(prevBlock.props.id)
152-
);
153-
row.memo = [prevBlock.props.label, false];
154-
prevBlock.patch(row);
155-
}
156-
157159
prevBlock = block;
158160
};
159161

0 commit comments

Comments
 (0)