-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fix useStore composable losing reactivity when used in uxStore #4937
Conversation
const store = useStore() | ||
export default function usePermissions (store = null) { | ||
if (store !== null) { | ||
store = store.state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for readability and consistency, can we make this variable state
please?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4937 +/- ##
==========================================
- Coverage 78.64% 78.59% -0.05%
==========================================
Files 324 325 +1
Lines 15265 15296 +31
Branches 3507 3512 +5
==========================================
+ Hits 12005 12022 +17
- Misses 3260 3274 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -37,7 +37,7 @@ const getters = { | |||
return state.tours.education | |||
}, | |||
mainNavContexts: function (state, getters, rootState, rootGetters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these be store
and rootStore
?
Given that the input to usePermissions
is store
, but you're passing a variable called rootState
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would depend on the context where they are used, I used the naming vuex describes them in their api. It would be better if i'd change the argument name in the composable to rootState to match it
Can confirm this hasn't fixed the issue for me. To reproduce consistently:
|
Debugging this myself, and found that in Investigating further... |
Very nice catch! Back to the drawing board but at least now i have something to work with |
If I hardcode:
Then the |
That's what i though i was fixing, i assumed that the permissions mixin was failing but I was working blindfolded until now. Now that I can reproduce it consistently i can get to the bottom of it easier |
Boils down to a few circular dependencies going on, as well as race conditions between multiple watchers. This |
Calling I need to call that a night, but you have enough to go on in order to get this fixed in the morning hopefully. |
Fix pushed in #4949 this can be closed |
Description
Main train of thought after reproducing the issue locally and noticing that the mainNavContexts was undefined which prevented the mainNav's nearestContextualMenu watcher to set the mainNavContext due to it's safeguard is that the useStore composable is losing store reactivity and causing the uxStore mainNavContexts getter to fail.
Related Issue(s)
closes #4797
Checklist
flowforge.yml
?FlowFuse/helm
to update ConfigMap TemplateFlowFuse/CloudProject
to update values for Staging/ProductionLabels
area:migration
label