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

Follow react rules of hooks #1228

Merged
merged 4 commits into from
Jul 14, 2024
Merged

Follow react rules of hooks #1228

merged 4 commits into from
Jul 14, 2024

Conversation

kirtangajjar
Copy link
Member

Description of the Change

Follow react rules of hooks

Closes #1205

How to test the Change

  1. Start on a test site running WP 6.5 RC 3 and Distributor.
  2. Edit a post/page, and create a new synced pattern.
  3. Click on the synced pattern, and then click 'Edit original' in the block toolbar to open the synced pattern in the new editor.
  4. Make edits and save them -- best I can tell they save fine!
  5. Click the 'back' button to return to the post/page editor; note that the error displays there initially, too.

Changelog Entry

Fixed - JS synced patterns editor

Credits

Props @kirtangajjar

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@kirtangajjar kirtangajjar requested a review from a team as a code owner June 15, 2024 16:14
@kirtangajjar kirtangajjar requested review from iamdharmesh and peterwilsoncc and removed request for a team and iamdharmesh June 15, 2024 16:14
@github-actions github-actions bot added this to the 2.1.0 milestone Jun 15, 2024
@github-actions github-actions bot added the needs:code-review This requires code review. label Jun 15, 2024
Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

This looks good, just a few nit picks to remove comments that are no longer accurate.

) {
return null;
}

// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed.
// eslint-disable-next-line no-shadow

// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed.
const postType = useSelect( ( select ) =>
select( 'core/editor' ).getCurrentPostType()
);

// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed.
// eslint-disable-next-line no-shadow -- permission checks are needed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line no-shadow -- permission checks are needed.
// eslint-disable-next-line no-shadow

'#wp-admin-bar-distributor'
);

// eslint-disable-next-line no-shadow -- permission checks are needed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line no-shadow -- permission checks are needed.
// eslint-disable-next-line no-shadow

select( 'core/editor' ).getCurrentPost()
);

// Ensure the user has proper permissions
Copy link
Collaborator

Choose a reason for hiding this comment

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

May as well fix the comment style while we're changing this code.

Suggested change
// Ensure the user has proper permissions
// Ensure the user has proper permissions.

Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

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

Tested and works well 👍

@Sidsector9 Sidsector9 merged commit 61331d1 into develop Jul 14, 2024
11 of 17 checks passed
@Sidsector9 Sidsector9 deleted the fix/sync-patterns-error-2 branch July 14, 2024 15:54
@dkotter dkotter modified the milestones: 2.1.0, 2.0.5 Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Distributor throws an error in WordPress 6.5 RC 3's new synced patterns editor
4 participants