wp-graphql / wpgraphql-acf

Re-architecture of WPGraphQL for ACF
GNU General Public License v3.0
80 stars 12 forks source link

Previewing ACF Fields not working (classic editor) #118

Closed jasonbahl closed 1 week ago

jasonbahl commented 10 months ago

Description

When making a change to an ACF Field and previewing the page, the un-saved changes are not being returned as the values for the fields in the GraphQL Query

Steps to reproduce

Gutenberg must not be active to reproduce.

See: https://github.com/AdvancedCustomFields/acf/issues/224, https://github.com/WordPress/gutenberg/issues/16006#issuecomment-657965028

  1. Create an ACF Field Group with a text field and assign it to the "Page" location
  2. Enter a value on the "text" field and publish the page
  3. query the page and see the published value of the text field
  4. change the value of the "text" field and click "preview" (not publish)
  5. query the page as an authenticated user with asPreview: true

expected behavior:

I expect to see the un-saved value of the text field as the value of the preview query

actual behavior:

I see the already published value, not the un-saved preview value

CleanShot 2023-11-07 at 14 33 47

PHP or JSON export of the ACF Field Group(s)

No response

Additional context

No response

WPGraphQL Version

1.18.0

WPGraphQL For ACF Version

v2.0.0-beta.5.1.0

ACF (Advanced Custom Fields) Version. Free or Pro?

latest, PRO

WordPress Version

6.3

PHP Version

8.1

Additional enviornment details

No response

Please confirm that you have searched existing issues in the repo.

Please confirm that you have disabled ALL plugins except for WPGraphQL, WPGraphQL For ACF, ACF, etc.

MKlblangenois commented 1 month ago

Hey @jasonbahl, have you any update on this issue? I'm facing the same on my side. Thanks!

josephfusco commented 1 month ago

This is possibly a duplicate of #154 which appears to have been resolved by #156.

@MKlblangenois can you provide more information about the specific problem you are facing?

The more info you can provide on your specific situation, the better we can help! šŸ™ŒšŸ¼

MKlblangenois commented 1 month ago

Hi @josephfusco!

After trying some query, I was able to confirm you that the issue is on all fields types. But, I discover more than just the fields that not in preview, but using asPreview: true on frontpage does nothing. I tried on other page and the asPreview work has excepted, but for the front page, they didn't.

I think that's not related to this issue because I've the same issue using Gutenberg (and this issue is related to classic editor).

If you see that screenshot, it show one of the ACF field in the frontpage template:

image

And the result for asPreview and preview node are different:

image



josephfusco commented 1 month ago

Hey @MKlblangenois, are you clicking the "preview" button on the post before running a query? That is a needed step in order for the preview data to be available.

This is what I'm getting on my end, which confirms to me that this has been resolved by #156.

CleanShot 2024-07-15 at 14 18 33@2x

josephfusco commented 1 month ago

Hey @MKlblangenois any chance you're able to provide more information? We are unable to reproduce this.

MKlblangenois commented 1 month ago

Hi @josephfusco!

After testing more, I can confirm that I got two issue on my side, related to preview (and not only for ACF field).

First: When I try to preview my Frontpage (defined has home page in reading settings), as you can see, the "asPreview" didn't return true to isPreview, I need to go to the preview node to get it.

https://github.com/user-attachments/assets/7d75333c-3b9d-4e89-a51f-a7380e625bf7

image

Second, related to ACF preview fields:

I didn't get the preview of my ACF fields even if I trigger my preview button, the_content is well modified to display the preview, even on the default WordPress theme but not for ACF field in GraphQL.

image

Here's my plugins versions:

Plugins Version
ACF Pro 6.3.4
WPGraphQL 1.27.2
WPGraphQL Content Blocks 4.0.1
WPGraphQL for ACF 2.4.1
WPGraphQL Offset Pagination 0.2.0

I use WordPress 6.6.1 with Twenty Twenty-Four 1.2

jasonbahl commented 1 month ago

@MKlblangenois hey! Thanks for the follow-up on this issue.

Since you are using the Block Editor, unfortunately there's a core WordPress bug (as mentioned in the issue description (See: https://github.com/AdvancedCustomFields/acf/issues/224, https://github.com/WordPress/gutenberg/issues/16006#issuecomment-657965028)) that prevents meta from being previewed when using the Block editor.

This is a core WordPress bug, and is not a bug within WPGraphQL, Advanced Custom Fields or WPGraphQL for ACF.


As far as the home page issue, we have not been able to reproduce this.

Can you provide clear steps to reproduce, starting from a clean WordPress install? Possibly there's some settings we have configured differently or some other plugin or custom code at play? For now, we've not been able to reproduce.

jasonbahl commented 1 week ago

Closing as I believe the original issue has been resolved. Please open a new issue with specific details and steps to reproduce and reference this issue if relevant.