Skip to content

Commit d308e26

Browse files
committed
fix selected collections on search
1 parent f92ae0b commit d308e26

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/compass-data-modeling/src/components/new-diagram-form.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,27 @@ function SelectCollectionsStep({
141141
})}
142142
columns={[['id', 'Collection Name']]}
143143
onChange={(items) => {
144-
const selectedItems = items
144+
// When a user is searching, less collections are shown to the user
145+
// and we need to keep existing selected collections selected.
146+
const currentSelectedItems = selectedCollections.filter(
147+
(collName) => {
148+
const item = items.find((x) => x.id === collName);
149+
// The already selected item was not shown to the user (using search),
150+
// and we have to keep it selected.
151+
return item ? item.selected : true;
152+
}
153+
);
154+
155+
const newSelectedItems = items
145156
.filter((item) => {
146157
return item.selected;
147158
})
148159
.map((item) => {
149160
return item.id;
150161
});
151-
onCollectionsSelect(selectedItems);
162+
onCollectionsSelect(
163+
Array.from(new Set([...newSelectedItems, ...currentSelectedItems]))
164+
);
152165
}}
153166
></SelectTable>
154167
</FormFieldContainer>

0 commit comments

Comments
 (0)