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

Refactor SuggestionsList to use hooks and change class to function component #36924

Merged

Conversation

amustaque97
Copy link
Member

@amustaque97 amustaque97 commented Nov 27, 2021

Description

Introduced functional component. In the component I'm using useState, useEffect.
Renamed a few variables to get rid of syntax errors/conflicts. Tested the component and
it is working as expected.

How has this been tested?

  1. In wp admin go to tags page.

image

2. Create multiple tags

image

  1. Edit or create new post.

  2. In the settings, try to add new tags.

  3. It will show suggestion list drop-down

image

  1. Select few tags
  2. Publish the post.

Screenshots

Types of changes

Code Quality / Refactor

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

…mponent

Introduced functional component. In the component I'm using useState, useEffect.
Renamed a few variables to get rid of syntax errors. Tested the component and
it is working as expected.
@ZebulanStanphill ZebulanStanphill added [Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality labels Nov 27, 2021
There was an error saying scrollIntoView function not found. I was not
importing it properly now in this commit I have renamed scrollIntoView function
from dom-scroll-into-view package is renamed as scrollView. I had to do this because
there is already props with the same name ie scrollIntoView. Component test case was
failing because of issue on the same lines that is now fixed.

There was another error related to not using act from react-dom/test-utils package in
test case. I have fixed it. All component test case are passing now.
Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

Thank you @amustaque97 for working on this ✌️

I'm going to give this a proper look later (either by end of day or on Friday), but I gave a quick look and code changes overall look good to me.

@ciampo
Copy link
Contributor

ciampo commented Dec 18, 2021

Hey @amustaque97, sorry if I haven't managed to take a proper look at this yet, but I had a few unforeseen PRs that took precedence. I will probably be able to do to in the new year, since I'm going to be AFK in the next couple of weeks. Hope that's ok!

- Add `noop` to reduce number of functions creation
- Move  emptyList to a const then use it
- Move `handleMouseDown` to top of the file to avoid recreating it on every render
@amustaque97
Copy link
Member Author

All review comments looks logical to me. I have addressed review comments. Thank You for the review. 😄

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

Thank you for working on this, @amustaque97 !

I took some time, had a proper look at the code and left some comments

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the feedback! Not crucial, but in the future it would be even better if you could split different sets of changes over separate commits

I just left a minor comment, otherwise the code changes LGTM and tests well.

Could you also add an entry to the CHANGELOG ?

@ciampo ciampo merged commit ef0e22a into WordPress:trunk Jan 6, 2022
@github-actions github-actions bot added this to the Gutenberg 12.4 milestone Jan 6, 2022
@amustaque97 amustaque97 deleted the refactor/suggestion-list-component branch January 6, 2022 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants