fix(content-manager): add optional chaining because listRef may not have a node attached (#18093)

This commit is contained in:
Josh 2023-09-18 10:24:01 +01:00 committed by GitHub
parent 36b8dc9438
commit a472dbc410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -196,13 +196,13 @@ const RelationInput = ({
updatedRelationsWith.current === 'onChange' && updatedRelationsWith.current === 'onChange' &&
relations.length !== previewRelationsLength relations.length !== previewRelationsLength
) { ) {
listRef.current.scrollToItem(relations.length, 'end'); listRef.current?.scrollToItem(relations.length, 'end');
updatedRelationsWith.current = undefined; updatedRelationsWith.current = undefined;
} else if ( } else if (
updatedRelationsWith.current === 'loadMore' && updatedRelationsWith.current === 'loadMore' &&
relations.length !== previewRelationsLength relations.length !== previewRelationsLength
) { ) {
listRef.current.scrollToItem(0, 'start'); listRef.current?.scrollToItem(0, 'start');
updatedRelationsWith.current = undefined; updatedRelationsWith.current = undefined;
} }
}, [previewRelationsLength, relations]); }, [previewRelationsLength, relations]);