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

Shared Content not loading properly #166

Closed
wedgberto opened this issue Nov 19, 2024 · 5 comments · Fixed by #169
Closed

Shared Content not loading properly #166

wedgberto opened this issue Nov 19, 2024 · 5 comments · Fixed by #169
Assignees
Labels
bug Something isn't working released

Comments

@wedgberto
Copy link

When navigating to a URL generated by the Casbin editor Share button, the content loads for a split second and then reverts to the default for the Model that the config was based on.

My example was based on "RBAC with domains/tenants", and the default for this Model is what I am left viewing after navigating to the shared URL, despite the shared values frustratingly flickering into view for a split second.

When not changing the base Model i.e. ACL the share URL works - https://editor.casbin.org/#58SA4DACF
When changing the base Model e.g. "RBAC with domains/tenants" the default for that Model is what ends up displayed - https://editor.casbin.org/#562HX9RD8 (policy and request items should all begin with x, but do not. e.g. xalice, xdomain1, xdata1, xread)

@hsluoyz
Copy link
Member

hsluoyz commented Nov 19, 2024

@wedgberto can you provide a demo video?

@wedgberto
Copy link
Author

wedgberto commented Nov 19, 2024

It's more difficult than you'd think to screen capture it actually. The use of # in the URL makes it fiddly to convince web browsers to refresh the page (but that's a different issue). This gif has the three frames showing the flashing in and out of the shared info slowed down for visibility.
casbin-editor-load-shared
This was using the share URL https://editor.casbin.org/#562HX9RD8

@wedgberto
Copy link
Author

A quick clone and build indicates that the loading of the model kind state is what is causing this. React useState is async and it seems that setting the model kind here https://github.com/casbin/casbin-editor/blob/6f34b11b3cef82a127424cf931429d85e8ff8cbd/app/components/editor/hooks/useIndex.tsx#L57C11-L61C12 is the last state update to complete and apparently clobbers the state updates of the loaded shared info. I hacked a fix to kind of prove this by deferring the setting of the model/policy/request shared content in a SetTimeout, so am pretty sure it's just the order of completion of these async operations.

@wedgberto
Copy link
Author

I'm new to React so not sure my fix is the best, but I've created PR #167

@hsluoyz
Copy link
Member

hsluoyz commented Nov 23, 2024

🎉 This issue has been resolved in version 1.24.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
2 participants