-
Notifications
You must be signed in to change notification settings - Fork 80
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
Always update schema data in redux #974
Conversation
…anged regardless of its ID set matching Fixes silverstripe#960
Further to this, there are a few sections of code here which compare ID's and whatnot to see if the data has "changed" I'd like to have a look at removing all of that stuff and start assuming that we're passing around immutable things which could change at any point, it'll remove some of the edge cases like this one which seem to pop up in this module. |
Hmmmn. My initial reaction to this is that we're breaking forms that have been changed but unmounted from the DOM. This happens now with form fields in elemental, when the form is "collapsed" the form state is saved in redux but the DOM elements are actually unmounted. I don't think it's "correct" to assume that redux is always stale. I'll do a more detailed review soon. |
@ScopeyNZ I don't think that we should care if it is stale or not ;) In this case, the alternative path was to perform more detailed checks of the "deep" copy of the data, which makes the comparators much more complex than they are currently and IMHO they are a bit useless - if we're using a store then we should push everything into the store all the time and let it sort itself out, right? |
Either the initial state (usually given in the form of a data attribute or a "form schema" request) is stale or redux is stale. I think we do have to care if it's stale. The issue linked is probably caused by the fact that the component is remounted with the correct "initial" data - but really it should've been added to redux and the component would have updated. It's probably not doing that because we're hitting our weird "oh it's entwine but it's also React/redux" ecosystem. If we merge this we'll almost certainly reintroduce a bug where edited file details are removed when the UploadField is hidden (removed from the DOM) and then re-shown. Perhaps what we should do is bust redux stores when the CMS form is saved. I'm not really sure what's the best idea here. It's all a bit messy. |
Yeah it is a problem with the entwine re-population of the form on a PJAX request on save. I agree that it is really messy :) When you say "hidden and then re-shown" what context is that in? As far as I was aware editing of files now happens within the assets section, no longer on the page where this component is shown? |
The case I'm thinking of is a file block in elemental (^4). You can upload a file, or adjust details on the file (using the asset-admin modal that appears when you click the UploadField). Then you may collapse the form again before either saving or re-expanding the form. Now that you mention it you might not be able to actually edit meta-data on the file this way, but you can definitely change the chosen file or upload one without saving it, and then use the page level save to actually persist the changes. |
It might be that a lot of the code that makes no sense to me in this module has been written to help with that elemental case rather than its stock standard functionality? Should we instead move some of that required functionality up a level and implement a UploadField which suits those specific needs for elemental? I'd be happy to have a look at doing that if you agreed @ScopeyNZ |
Think of it as a lot of the code has been rewritten to support use of this component with " Implementing a new higher level (order 😉 ) component is a good idea and makes a lot of sense, but I would prefer that we implement that to support the entwine context (not the other way around) as the goal future state means that everything is React and we can delete all the entwine compatibility code. |
I've spent some time looking into what might get broken and I cannot find anything at the moment. |
I don't think it's a good idea to merge this and deal with a problem that might show up when I'm pretty confident one will show up. If you checkout this patch and play around with upload forms in elemental I think you'll probably see an issue relatively quickly where state is lost (or incorrectly retained) in the UI. I haven't had any opportunity to test this yet (I'm not working with SS much right now) but I can still probably find a bit of time to play around with this soonish |
I also want to mention that I think the problem that I'm pretty sure will occur is (in my opinion) higher impact than the bug that is being fixed here. |
that's my point. I actually been trying to find what's broken anywhere with this patch applied on my localhost - neither tests nor elemental blocks nor standalone upload field seem to get broken with it. Everything seems to be working just fine to me.
Good point. I think if that's critical enough, then it should come up in regression testing quite quickly, then we would be able to rethink our approach to how we fix it or return this code with more in-depth comparison, rather than just checking IDs. |
This pull request hasn't had any activity for a while. Are you going to be doing further work on it, or would you prefer to close it now? |
I won't be, I still think that this fixes the issue but the higher order components aren't really part of the concern for this. I'd prefer that we merged it and fixed the issue thats been around for a long time, or look at actually fixing the issue upstream rather than blocking a fix. |
@ScopeyNZ do you feel strongly about blocking this, or should we just merge and move on? |
I'm thinking hold old merging this for now, there's other related issues around files and state not being in sync and they kind of all need to be fixed together. I believe these two issues are also related
Unfortunately the whole |
Closing in favour of #1263 |
As the underlying data may have changed regardless of its ID set matching
Fixes #960