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

Fix parseAttribute Function to Handle Multiple Nodes #243

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

theodesp
Copy link
Member

@theodesp theodesp commented Jun 13, 2024

Description

This PR addresses a bug in theparseAttribute function where it only checked the first node for the specified attribute when the selector was empty. The function has been updated to iterate through all nodes that match the selector and return the attribute value if found. Additionally, unit tests have been updated and expanded to cover these changes.

Fixes

#239

Testing

  1. Add a core table into a page and adjust the alignment on a column (not the alignment of the table).
  2. Add this into your page query:
    editorBlocks {
      ... on CoreTable {
        attributes {
          body {
            cells {
              align
            }
          }
          foot {
            cells {
              align
            }
          }
          head {
            cells {
              align
            }
          }
        }
      }
    }

Expected result. Align value should not be null

"data": {
    "posts": {
      "nodes": [
        {
          "editorBlocks": [
            {
              "name": "core/table",
              "attributes": {
                "body": [
                  {
                    "cells": [
                      {
                        "align": "center"
                      },
                      {
                        "align": null
                      }
                    ]
                  },
                  {
                    "cells": [
                      {
                        "align": "center"
                      },
                      {
                        "align": null
                      }
                    ]
                  }
                ],
                "foot": [],
                "head": [
                  {
                    "cells": [
                      {
                        "align": "center"
                      },
                      {
                        "align": null
                      }
                    ]
                  }
                ]
              }
            }
          ]
        },

@theodesp theodesp requested a review from a team as a code owner June 13, 2024 13:27
Copy link

changeset-bot bot commented Jun 13, 2024

🦋 Changeset detected

Latest commit: 21adb13

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wpengine/wp-graphql-content-blocks Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@ChrisWiegman ChrisWiegman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@theodesp theodesp merged commit 39e8181 into main Jun 17, 2024
9 checks passed
@theodesp theodesp deleted the fix-parse-attributes-no-selector branch June 17, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants