-
-
Notifications
You must be signed in to change notification settings - Fork 652
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 internalUrl Widget to Reflect Prop Changes via onChangeBlock #6036
Conversation
✅ Deploy Preview for plone-components ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I've set up a test using coresandbox to demonstrate the bug I'm referring to. |
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.
@dobri1408 you've renamed TestBlock Edit.jsx component InputBlockEdit and your InputBlock/View.tsx has name TestBlockView, put the naming correctly for your given new block and don't modify the TestBlock
Sorry for the mistake, I have put the right name back. |
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.
Would it be simpler to make this widget a controlled component (i.e. stop managing its own value as internal state and always show the value from props) instead of trying to sync changes from the value
prop to the widget state?
- Also removed setting of undefined on clearing opting to set value to empty string to avoid warning that we switch from controlled to uncontrolled component.
@davisagli I've modified the logic to take the value from the prop as you've suggested. One change that I am pushing for is to avoid having undefined value when we clear because React complains about it about controlled vs non controlled inputs. This video shows the behavior in action |
@ichim-david I think that's probably okay since an empty string evaluates to boolean False in Javascript -- as long as the backend accepts it when configuring a content rule. The other option would be setting it to |
@davisagli you can't We get warnings and it doesn't work well if we have null or undefined. This is why I propose the empty string since it evaluates to false and it keeps the value in sync without the need for the use effect |
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.
@ichim-david The empty string works fine where this is used -- and in the context where it is used for content rules, the empty value will never be sent to the backend, since the field is required.
* main: (63 commits) Release 18.0.0-alpha.35 Release @plone/types 1.0.0-alpha.16 (fix): export getFieldURL from Url.js in helpers (#6100) Improve container detection, `config.settings.containerBlockTypes` is no longer needed (#6099) Support nested directories in public folder add-on sync folders both … (#6098) Release 18.0.0-alpha.34 Add generated new declarations for a34, just in case (#6097) Release @plone/slate 18.0.0-alpha.13 Release @plone/registry 1.6.0 Release @plone/types 1.0.0-alpha.15 Add support for reading the add-ons `tsconfig.json` paths (#6096) Fixes #6046 pass proper defaults to align and size fields of Image block (#6093) bug fix. relations control panel. Restrict eglible relation targets a… (#6092) Fix Uncaught RangeError: date value is not finite in DateTimeFormat.format (#6088) Add optional `token` parameter to ploneClient initialization (#6077) Blocks Layout Navigator (#5642) Fix internalUrl Widget to Reflect Prop Changes via onChangeBlock (#6036) [types] Improve styleClassNameExtenders types, Icon component JSDoc t… (#6095) Fix link in pop-up RelationsMatrix.jsx (#6085) Fix deselecting lists. (#6080) ...
* main: (42 commits) Release 18.0.0-alpha.35 Release @plone/types 1.0.0-alpha.16 (fix): export getFieldURL from Url.js in helpers (plone#6100) Improve container detection, `config.settings.containerBlockTypes` is no longer needed (plone#6099) Support nested directories in public folder add-on sync folders both … (plone#6098) Release 18.0.0-alpha.34 Add generated new declarations for a34, just in case (plone#6097) Release @plone/slate 18.0.0-alpha.13 Release @plone/registry 1.6.0 Release @plone/types 1.0.0-alpha.15 Add support for reading the add-ons `tsconfig.json` paths (plone#6096) Fixes plone#6046 pass proper defaults to align and size fields of Image block (plone#6093) bug fix. relations control panel. Restrict eglible relation targets a… (plone#6092) Fix Uncaught RangeError: date value is not finite in DateTimeFormat.format (plone#6088) Add optional `token` parameter to ploneClient initialization (plone#6077) Blocks Layout Navigator (plone#5642) Fix internalUrl Widget to Reflect Prop Changes via onChangeBlock (plone#6036) [types] Improve styleClassNameExtenders types, Icon component JSDoc t… (plone#6095) Fix link in pop-up RelationsMatrix.jsx (plone#6085) Fix deselecting lists. (plone#6080) ...
* main: (31 commits) Release 18.0.0-alpha.35 Release @plone/types 1.0.0-alpha.16 (fix): export getFieldURL from Url.js in helpers (#6100) Improve container detection, `config.settings.containerBlockTypes` is no longer needed (#6099) Support nested directories in public folder add-on sync folders both … (#6098) Release 18.0.0-alpha.34 Add generated new declarations for a34, just in case (#6097) Release @plone/slate 18.0.0-alpha.13 Release @plone/registry 1.6.0 Release @plone/types 1.0.0-alpha.15 Add support for reading the add-ons `tsconfig.json` paths (#6096) Fixes #6046 pass proper defaults to align and size fields of Image block (#6093) bug fix. relations control panel. Restrict eglible relation targets a… (#6092) Fix Uncaught RangeError: date value is not finite in DateTimeFormat.format (#6088) Add optional `token` parameter to ploneClient initialization (#6077) Blocks Layout Navigator (#5642) Fix internalUrl Widget to Reflect Prop Changes via onChangeBlock (#6036) [types] Improve styleClassNameExtenders types, Icon component JSDoc t… (#6095) Fix link in pop-up RelationsMatrix.jsx (#6085) Fix deselecting lists. (#6080) ...
When you update a block's properties using onChangeBlock, the widget may not show these changes because its state isn't updating correctly.
screen-capture.5.mp4
The expected behavior is that the URL field in the sidebar will update with the new URL value, as it was updated by onChangeBlock.
📚 Documentation preview 📚: https://volto--6036.org.readthedocs.build/