Skip to content

Related items module #191

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

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

timio23
Copy link
Contributor

@timio23 timio23 commented Apr 26, 2025

No description provided.

@ukmadlz ukmadlz self-requested a review April 28, 2025 19:49
@formfcw formfcw requested review from formfcw and removed request for ukmadlz May 22, 2025 10:44
Copy link
Contributor

@formfcw formfcw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @timio23! Great work 🚀 I really like this extension ❤️

However, besides the code comments, I found the following bugs:

  • As soon as we open a junction collection (M2M or M2A), we get an error on the server, but not in the studio. From that point on, nothing works and we have to restart Directus. Please be sure to include proper error handling so that the server does not crash!
    • If I have an M2A on a collection and also the Related Items interface. When I then click on an item in the M2A and edit it in the drawer, then open the same item in the Related Items interface, I get the same error on the server as above.
  • Settings are not reactive, so we have to refresh the browser after updating.
  • If there are no related items, the interface will display a gray box with a loading cursor. Please display a notice instead: No (related) items found or similar.
  • M2A bug: Given a main collection with an M2A field that references other collections, but also the main collection itself. Then, when creating an item with references to all collections except the main collection, it shows a tab with all items but 4 occurrences of each. When I open one in the drawer, I get the same, but with 8 more.
    • A similar bug occurs, when clicking on a related item from your interface and then in the opened drawer where we also have this interface, switching tabs between “All” and a collection that has an M2A relationship to the main collection. When switching tabs, the items on the “All” tab are duplicated each time, we activate it.
  • Even if we display only 1 item, the list will appear densed based on the total number of items.
  • If you click on the label of the interface to edit a raw value, this value is added to the form values and the save button becomes active. Please be sure to prevent this by setting hideLabel: true in the interface settings!
    • On the other hand, when opening a related item in the drawer that is not present as a reverse relationship/interface and then editing this item, we see the edits updated in the interface, but the value is not stored so we can save it. With the above in mind, please find a solution to either prevent editing or allow it and make it work properly.

Copy link
Contributor

@formfcw formfcw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @timio23, Here are some more change requests from the design team:

Please swap the colors so that the button is the primary color and the badge is the primary accent color.

image

For the dropdown menu in Settings, please ensure that the menu width matches the field width. If the wider field already solves this issue, then ignore this.

Screenshot 2025-05-28 at 9 31 38 AM

Thank you!

@timio23
Copy link
Contributor Author

timio23 commented May 29, 2025

Update from me, I've got most of these sorted but still working through the more complex issues

@timio23
Copy link
Contributor Author

timio23 commented May 30, 2025

Hi @formfcw, you mentioned getting errors when adding the interface to a junction table. Is there a use case for this? It would only show what is already available - eg one item from the left and one item from the right. Any objections to me excluding junction tables from the settings?

@formfcw
Copy link
Contributor

formfcw commented May 30, 2025

Hi @formfcw, you mentioned getting errors when adding the interface to a junction table. Is there a use case for this? It would only show what is already available - eg one item from the left and one item from the right. Any objections to me excluding junction tables from the settings?

The server crashes and needs to be restarted. We need a solution to this problem. It's up to you whether that means preventing usage in junction tables or making the interface work.

@timio23
Copy link
Contributor Author

timio23 commented May 31, 2025

Hey @formfcw, I've resolved most of the issues and requests. There's just one I'm stuck on - the reactive settings. I used a hook extensions to create the fields when the settings are updated however this runs on the server side and can't hydrate the fields on behalf of the user. Are you aware of another way to trigger hydration after settings are saved?

/>
</template>

<style lang="css" scoped>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the alignment of the text elements here:

alignment and duplicates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added css to fix alignment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still encountering this issue:

alignment

@formfcw
Copy link
Contributor

formfcw commented Jun 3, 2025

Also, please take a look at the unresolved issues listed above:

  * [ ]  If I have an M2A on a collection and also the Related Items interface. When I then click on an item in the M2A and edit it in the drawer, then open the same item in the Related Items interface, I get the same error on the server as above.
  * [ ]  A similar bug occurs, when clicking on a related item from your interface and then in the opened drawer where we also have this interface, switching tabs between “All” and a collection that has an M2A relationship to the main collection. When switching tabs, the items on the “All” tab are duplicated each time, we activate it.

@timio23
Copy link
Contributor Author

timio23 commented Jun 6, 2025

@formfcw that should be all the issues resolved now

Copy link
Contributor

@formfcw formfcw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @timio23 for your changes!

A few things:

  • Please fix the alignment as described above
  • Given that we have an M2A builder interface and the Related Items Extension on the same item. When we edit an item in the M2A the changes are not reflected in the Related Items Interface. However, if we then open the same item via the Related Items Interface and edit the field, it will be saved, but not updated in the M2A interface, where the previous edits still exist. Please, either make it behave as expected or you set the form in the drawer to appear as read-only. To do so, simply add a disabled prop to <drawer-item> and remove the unused parts (saveEdits, …).
  • We are still having trouble with duplicate entries appearing when switching tabs — see the video:
duplicates.mov

@timio23
Copy link
Contributor Author

timio23 commented Jun 30, 2025

  • We are still having trouble with duplicate entries appearing when switching tabs — see the video:

Hi @formfcw, I can't seem to replicate this issue. I've tested on Safari, Chrome and Firefox using a vanilla installation of Directus 11 and it's all working correctly including the API response. From the video, it seems that some results are "sticking", is there anything unique about your set up? I'm testing use Postgres and SQLite with the browsers mentioned above on my Mac. Maybe another extension is interfering?

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.

3 participants