Skip to content

Fix: Error when calling the PostActions view-post callback#63460

Merged
youknowriad merged 1 commit intoWordPress:trunkfrom
sejas:update/post-actions-on-action-performed
Jul 12, 2024
Merged

Fix: Error when calling the PostActions view-post callback#63460
youknowriad merged 1 commit intoWordPress:trunkfrom
sejas:update/post-actions-on-action-performed

Conversation

@sejas
Copy link
Copy Markdown
Contributor

@sejas sejas commented Jul 11, 2024

What?

Fixes the error thrown when clicking PostActions View post in the editor.

Why?

In #63120 we added support for onActionPerformed at action level, but I've observed the object is undefined in all the cases.

I could check. onActionPerformed is only used at hook level instead. If we need to remove the logic that unpacks argsObject, I'm happy to update this PR or open a new one.

How?

Add a condition in case the callback options argsObject is undefined.

Testing Instructions

  1. Go to edit a post. For example /wp-admin/post.php?post=1&action=edit.
  2. Open the console in Chrome Dev Tools
  3. Click in the three dots to open the Actions dropdown menu.
  4. Click in View
  5. Observe there are not any issues in the console
  6. Observe the browser did open a new window with the post frontend

Testing Instructions for Keyboard

Screenshots or screencast

Before

post-action-view-before.mp4

After

post-action-view-after.mp4

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 11, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sejas <antoniosejas@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jul 11, 2024
@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @sejas! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@sejas
Copy link
Copy Markdown
Contributor Author

sejas commented Jul 11, 2024

@jorgefilipecosta , could you take a look if this is the right direction for this fix? Thank you!

@Mamaduka Mamaduka added the [Type] Bug An existing feature does not function as intended label Jul 12, 2024
Copy link
Copy Markdown
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

I can reproduce the error, and the fix makes sense.

I'm not super familiar with post actions, so will leave final approval to @jorgefilipecosta.

@youknowriad
Copy link
Copy Markdown
Contributor

This makes sense to me 👍

Copy link
Copy Markdown
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

Tha change look good, thank you for this fix 👍

@youknowriad youknowriad merged commit 4777ebd into WordPress:trunk Jul 12, 2024
@sejas sejas deleted the update/post-actions-on-action-performed branch July 12, 2024 11:59
@github-actions github-actions bot added this to the Gutenberg 18.9 milestone Jul 12, 2024
@Mamaduka Mamaduka added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jul 12, 2024
andrewserong pushed a commit that referenced this pull request Jul 15, 2024
Co-authored-by: sejas <antoniosejas@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
@andrewserong
Copy link
Copy Markdown
Contributor

I just cherry-picked this PR to the release/18.8 branch to get it included in the next release: e0afea2

@andrewserong andrewserong removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jul 15, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jul 18, 2024
Co-authored-by: sejas <antoniosejas@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PostAction View Post returns an error

5 participants