Skip to content

feat: add the ability to link existing documents in the join field #12029

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

illright
Copy link

@illright illright commented Apr 7, 2025

What?

This PR adds a new button to the Join field UI to take an existing document from the joined collection and link it to this joining document instead.

the join field UI with two buttons titled 'Choose from existing' and 'Add new'

Why?

This is a custom functionality that I needed as part of my own usage of Payload. I found the integration to be a bit difficult — I had to modify the label component and extend it in width up to the Add new button to give an impression of a second action. Not to mention that after sending a PATCH request to do the linking, I had to call window.location.reload() because I couldn't come up with a better way to invalidate the table from within a custom component.

Since the new functionality was mostly using existing Payload components, I figured I'd try to contribute it back in case you decide that it's useful.

How?

This uses the ListDrawer element to display a slide-out panel to browse existing documents that can be linked to the current document.

Note

This PR is still not finished — after selection, the document isn't actually being linked. I wanted to get your input on whether this contribution is welcome, and if so, what would be the best way to implement the linking? The only thing I can think of is a fetch call, but perhaps there's a better way to do updates from inside Payload client components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant