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

example async drag-n-drop #4146

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

Conversation

drewfish
Copy link

@drewfish drewfish commented Dec 25, 2024

This example builds on the existing Trello Cards example and adds 2 features:

  • Uses app.storage.tab for the currently-dragged card. This is more "production ready" than a global.
  • Introduces some "processing time" between when the card is dropped and when it's "committed". This is to demonstrate handling drag-n-drop which takes time to take effect.

The approaches in this PR might not be the best 😞

  • I didn't use the nice OOP approach found in examples/trello_cards/draganddrop.py. I think there might be a way to do that. It was getting tricky, though, in my mind when I started thinking about also being able to drag columns to re-order them.
  • In order to managed the skeletons, I had to monkey around in the internals of the slots 😞. I think this might be refactorable if there's a new ui.column.replace(old_element, new_element) or something like that. (I might attempt that in a separate PR.)
Screen.Recording.2024-12-25.at.11.28.35.mov

Copy link
Contributor

@falkoschindler falkoschindler left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this pull request, @drewfish! Adding support for async drop handlers sounds like a reasonable extension.

But I have some concerns about your approach of adding a second app to the example:

  • I would prefer improving the existing app rather than adding another one.
  • As far as I understand, you didn't stick with the OOP approach because you "started thinking about also being able to drag columns". But dragging columns isn't part of this example, so I don't see a reason to change the whole architecture (at least in this PR).
  • The on_drop function mixes basic drag&drop functionality (including skeletons) with user code (sleeping for one second in this example). This makes it hard to see how to apply the idea to a real-world scenario.
  • I'm not sure about the use of skeletons while dropping cards: Shouldn't the drop happen very quickly? Even if there is an async database call, it could run in the background after updating the UI.

I'd suggest to clarify the goal of this PR first before improving the implementation. Do we want to show how to support async drop handlers? Then we can modify the existing example pretty easily. Do we really want to show skeletons? Then we'd need to think about how to incorporate it into the existing example.

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.

2 participants