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

Empty values not getting saved in the post_content #14629

Closed
Balachandark opened this issue Mar 26, 2019 · 4 comments
Closed

Empty values not getting saved in the post_content #14629

Balachandark opened this issue Mar 26, 2019 · 4 comments
Labels
[Feature] UI Components Impacts or related to the UI component system [Status] Needs More Info Follow-up required in order to be actionable.

Comments

@Balachandark
Copy link

Describe the bug
I have created a new Heading block. For padding options, I have used the Range Control. I have provided 15 as the default value for it. I get the default value 15 in the editor. Whenever the value is changed the value gets updated to the post_content but when I reset the values to blank then the values are not updated to the post_content hence the default values are visible even if I save the block with empty values.

Expected behavior
I expected the empty values to be stored in the post_content so that I would be able to differentiate between the values that the user has provided and the default values.

Video
Please refer to this video - https://cl.ly/d04a60bae966.

Desktop (please complete the following information):

  • OS: Windows 8
  • Browser: Chrome
  • Version 73.0.3683.86 (Official Build) (64-bit)

Additional context

  • Gutenberg Version 5.3.0.
@swissspidy swissspidy added the [Feature] UI Components Impacts or related to the UI component system label Mar 26, 2019
@swissspidy
Copy link
Member

I don't see any bug here 🤔

If your default value is 15 and the user changes the value to 14 and then back to 15, why should it matter for your application whether the value is now 15 or empty.

And when you click reset, the value is removed and your default should be applied.

@swissspidy swissspidy added the Needs Technical Feedback Needs testing from a developer perspective. label Mar 26, 2019
@Balachandark
Copy link
Author

The problem that I am having is that I want the default values to be applied when the block is added to the page i.e. 15, but when the user resets the values then I don't want the default values to be applied, but as the user has provided empty values so it should inherit its parents CSS.

@aduth
Copy link
Member

aduth commented Apr 22, 2019

There were some recent revisions to how the RangeControl (and specifically the reset behavior) is implemented (see #12952). It may be worth testing again in the latest version of the plugin to see if the expected behavior is present.

To the original request, however: It is intentional that if a value is reset to its default, it would not be assigned in the generated attributes of a block. It is done this way so that, for example, the default could be changed in the future and all existing content which do not have a specific value assigned would automatically begin using this new default.

@aduth aduth added [Status] Needs More Info Follow-up required in order to be actionable. and removed Needs Technical Feedback Needs testing from a developer perspective. labels Apr 22, 2019
@youknowriad
Copy link
Contributor

Closing, let's reopen if needs more consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system [Status] Needs More Info Follow-up required in order to be actionable.
Projects
None yet
Development

No branches or pull requests

4 participants