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

Default and client-side registered attributes (e.g., "anchor") not available in server-side context #68

Closed
Zamfi99 opened this issue Jul 13, 2024 · 2 comments
Assignees
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@Zamfi99
Copy link
Contributor

Zamfi99 commented Jul 13, 2024

Describe the bug
Currently, there is a significant issue with default and client-side registered attributes, such as the anchor attribute, which are registered on the frontend and not in the backend. As a result, these attributes are not available in the server-side context, causing them to be missing in the API response. This discrepancy can lead to functionality problems and inconsistencies when handling blocks, particularly those relying on default attributes for proper rendering and behavior.

To Reproduce

  • Create a post and add any block that supports anchor
  • In the block settings go to "Advanced" and set an anchor
  • Attempt to retrieve the block attributes through the server-side API
  • Observe that the anchor attribute and other client-side registered attributes (if applicable) are missing in the API response

Expected behavior
Default attributes, such as anchor, along with client-side registered attributes on the frontend, should be consistently included in the API response.

Actual behavior
Specific default attributes, such as anchor, as well as client-side registered attributes on the frontend, are currently missing from the API response.

  • Client-side registered attributes may be included in the API response if their values differ from the default settings.

Proposed solution
To address this issue, I propose the creation of a custom block type registry that can be dynamically updated from within the Gutenberg editor on the frontend. While not the most ideal solution, it appears to be the most feasible approach. This registry will ensure that both default and custom attributes registered on the frontend are also available in the backend, thereby providing a consistent and reliable API response.

@Zamfi99 Zamfi99 added the bug Something isn't working label Jul 13, 2024
@smithjw1 smithjw1 added the wontfix This will not be worked on label Jul 15, 2024
@smithjw1
Copy link
Contributor

@Zamfi99, thanks for submitting this bug report. There are two separate issues here, one for default attributes, and one for custom attributes registered on the front end.

I've created issue #69 to track work on default attributes.

I've marked this issue as wont fix because we know the limitation on client-side registered attributes. We agree that your suggested solution would be the best approach. It is the one the WP GraphQL Gutenberg takes.

We have decided not to extend the plugin into the editor to capture client-side registered attributes for three reasons:

  1. Registering via block.json is the preferred method from Core.
  2. Tapping into the editor front-end is not ideal for end users.
  3. The additional maintenance cost of integration with maintaining a non-supported integration with the post editor.

We realize this limits the usefulness of the plugin for block attributes registered on the front end, but that is a trade-off we have decided to make.

@alecgeatches
Copy link
Contributor

Closing this issue in favor of #69. Please see this comment #69 (comment) for an anchor attribute workaround. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants