Bug fixes for the Edit User modal #134
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
KittenSquad/glewlwyd!134
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "edit-user-modal-bugfix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Squashes two bugs linked to the Edit User modal of the admin webapp:
<button disable=condition was the logical complement (NOT) of what it should have been.userstate object, thereby sandboxing any user info revisions within the modal, and preventing their propagation to other components (i.e. copy-by-reference is replaced by copy-by-value logic). There might be more elegant solutions to this bug.Thanks again @yrammos !
Although I totally agree with the goal, I'd change the method for the 2nd point.
With your PR, it seems that when a change is saved in the modal, the component App would still have the original data.
Also defining an inner function inside the
render()function is not elegant, especially since I'd apply the same change for all other components with modals: scheme, plugins, backends, etc.I'll look around to find another way to fix 2.
@babelouest I agree that the second point is addressed here with some quick and dirty hackery.
Meanwhile I added one more commit to this PR. The "source" dropdown in the "new user" modal would be initialized with a default source, but the state would not. (Therefore the user would still need to select that source to actually have it stored in the state.) Not to risk messing around with states, here I'm opting for the most naive solution, i.e. to initialize the drop down with a blank source name; this should be enough for the user to realize that a source actually must be selected (albeit at the tiny usability expense of lacking a "default" dropdown option).
Hesitantly indeed, I'm also removing
this.state.addfrom the OK<button disabled=condition. I think it prevented new user form submissions—kindly review and adjust if/as necessary. I'm not quite following the intended logic of the button state. Thanks as ever.Hello @yrammos ,
I've update your pull request in my branch yrammos-edit-user-modal-bugfix
Instead of deep copying data, I've used the good ol' JSON.stringify and JSON.parse to make a copy without copying the reference. Can you check that out?
Also, I'm wondering about the change in the
disabledbutton attribute. Can you describe a use case where the button disabled attribute was buggy?@babelouest thank you for developing this further. The
disabledattribute is puzzling and honestly I don't quite recall the conditions. I remember that the button was disabled when I attempted to create a new user, but I might have been working on a "dirty" revision with other temporary changes that interfered. If everything looks well on your end without thedisabledchange, please feel free to omit it; I'll then report back if I can reproduce.The
JSON.stringifyandJSON.parsemethod works quite well indeed, but will fail if the object contains aDateand other complex data. I'm sure you know this at least as well as I do, so the assumption is probably safe in this case, right? (Even "date" custom data would be stored as a string.)That's the beauty of the data model, only simple data types, there's no complex data like
DateorByteArray. In fact, the data comes from the API response which is in JSON format. That's why I'm confident the JSON.stringify and JSON.parse will do the job :)Concerning the
disabledattribute, you're right, I've seen bugs too. I'll get back soon about that.@babelouest confirming that your fix for the CLOSE button issue works well on my end.
@yrammos , I beleive your
disabledfix makes more sense than my old code, I'll use this change, if a bug appears after that, it'll be easier to fix anyway