) => {
onSelectionChange([...initialSelectedDocuments, doc]);
onDone();
},
@@ -287,13 +317,16 @@ export const DocumentMentionPicker = forwardRef<
) : (
{actualDocuments.map((doc) => {
- const isAlreadySelected = selectedIds.has(doc.id);
- const selectableIndex = selectableDocuments.findIndex((d) => d.id === doc.id);
+ const docKey = `${doc.document_type}:${doc.id}`;
+ const isAlreadySelected = selectedKeys.has(docKey);
+ const selectableIndex = selectableDocuments.findIndex(
+ (d) => d.document_type === doc.document_type && d.id === doc.id
+ );
const isHighlighted = !isAlreadySelected && selectableIndex === highlightedIndex;
return (