Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): make relationship fields update the collection when it is changed in the drawer dropdown #10338

Merged
merged 4 commits into from
Jan 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions packages/ui/src/elements/ListDrawer/DrawerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ListDrawerContent: React.FC<ListDrawerProps> = ({
onBulkSelect,
onSelect,
overrideEntityVisibility = true,
selectedCollection: selectedCollectionFromProps,
selectedCollection,
}) => {
const { closeModal, isModalOpen } = useModal()

Expand All @@ -43,7 +43,7 @@ export const ListDrawerContent: React.FC<ListDrawerProps> = ({
})

const [selectedOption, setSelectedOption] = useState<Option<string>>(() => {
const initialSelection = selectedCollectionFromProps || enabledCollections[0]?.slug
const initialSelection = selectedCollection || enabledCollections[0]?.slug
const found = getEntityConfig({ collectionSlug: initialSelection }) as ClientCollectionConfig

return found
Expand All @@ -59,15 +59,6 @@ export const ListDrawerContent: React.FC<ListDrawerProps> = ({
collectionSlug: selectedOption.value,
})

useEffect(() => {
if (selectedCollectionFromProps && selectedCollectionFromProps !== selectedOption?.value) {
setSelectedOption({
label: collections.find(({ slug }) => slug === selectedCollectionFromProps).labels,
value: selectedCollectionFromProps,
})
}
}, [selectedCollectionFromProps, collections, selectedOption])

GermanJablo marked this conversation as resolved.
Show resolved Hide resolved
const renderList = useCallback(
async (slug: string, query?: ListQuery) => {
try {
Expand Down
Loading