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 Icon Picker rendering empty when one item should be rendered #249

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

fabiankaegy
Copy link
Member

Description of the Change

The code to retrieve the icon to be rendered in the icon grid had a logical error in it. When it tried to calculate the index of the icon to render based on the position of the icon in the virtualized grid, the maths was adding +1 at the end to make its index human-readable instead of index 0 which we would need to actually render the correct icon.

This issue means that regardless of the state of the icon picker, the first icon in the list is not rendered. This becomes most obvious when there only is one icon like when you are searching and there is only one match.

Closes #248

How to test the Change

  1. Insert Icon Picker
  2. Search for an icon name that only occurs once. / Alternatively only register one singular icon

Changelog Entry

Fixed - Empty rendering of first item in Icon Picker due to index 0

Credits

Props @psorensen @TylerB24890 @fabiankaegy

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.

@fabiankaegy
Copy link
Member Author

I have pushed this fix to NPM as an alpha version so we can all test it on actual projects. To pull down the specific version run

npm i @10up/block-components@1.16.2-icon-picker.0

@github-actions
Copy link

Size Change: -2 B (0%)

Total Size: 53.5 kB

Filename Size Change
dist/index.js 53.5 kB -2 B (0%)

compressed-size-action

@Antonio-Laguna
Copy link
Member

@fabiankaegy this LGTM!

Copy link

@TylerB24890 TylerB24890 left a comment

Choose a reason for hiding this comment

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

Confirmed this seems to be working for me!

@fabiankaegy fabiankaegy merged commit 97c2e33 into develop Aug 23, 2023
@fabiankaegy fabiankaegy deleted the fix/icon-picker-indexing branch August 23, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icon Picker renders empty when only one item should be rendered
3 participants