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

Sortable and shiny modules are currently incompatible #100

Open
schloerke opened this issue Jun 2, 2023 · 2 comments · May be fixed by #95
Open

Sortable and shiny modules are currently incompatible #100

schloerke opened this issue Jun 2, 2023 · 2 comments · May be fixed by #95

Comments

@schloerke
Copy link
Collaborator

schloerke commented Jun 2, 2023

Hey @andrie & @schloerke,

I've spent a handful of hours trying to figure out what's going on here and it looks like the issue goes beyond just the update module, it appears that the handling of the shiny input ids in sortable is incompatible with shiny modules.
I've added a contrived example in 5c9f4f7 that can be run with the console open. Clicking either of the buttons does not trigger the input methods.

I'm trying to hunt down the differences in how the input_id is handled in this package compared to others, but I'm wondering if anyone has a better understanding of what all needs to change to standardize the handling of the input_id argument internally such that sortable works in a modularized shiny app?

Originally posted by @yogat3ch in #95 (comment)

@schloerke
Copy link
Collaborator Author

Ok. So {sortable} needs to not set the id values directly. Ex:

When these values are set, they are unaware of the NS that is being used within a module.


Reasoning:

  • update_bucket_list() calls session$sendInputMessage(id, msg). Link
  • Within a module, sendInputMssage will prepend the module's ID in front of the supplied id. Link
  • So the message in the example app is being sent to an id of "bucket_lists-bucket-list-bucket_list_group". ({namespace}-{sortableprefix}-{cssid}).

I'm too far removed from the code to remember why I used css_id and regular input_id`. Seems odd to me. 😞

If the css_id were to be altered by adding a suffix (rather than a prefix), it could be used within modules if exposed in the function api. But this seems like a bandaid on top of a bandaid. This change would most likely be a breaking change for some users.

Originally posted by @schloerke in #95 (comment)

I had proposed another solution but it does not fully work with modules. I think we need to revisit why we have both css_id and input_id and why css_id gets a prefix.

If we can at least make it a suffix, then module name spaces (shiny::NS()) can be applied

@yogat3ch
Copy link

yogat3ch commented Jun 3, 2023

Thank you for investigating and elaborating @schloerke 🙏

I think we need to revisit why we have both css_id and input_id and why css_id gets a prefix.

This seems like the key question, I was guessing that perhaps there was some reason related to how SortableJS works, but I'm not familiar enough with the library to know.

I assume this is something that needs input from the other devs working on sortable and I should standby before working on a PR?

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 a pull request may close this issue.

2 participants