-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Author Block: Refactor Settings panel to use Toolspanel #67965
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
Author Block: Refactor Settings panel to use Toolspanel #67965
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@im3dabasia, do you mind rebasing this PR on top of the latest trunk? |
@Mamaduka , I have merged the latest trunk branch into the current one. Please check at your convenience and looking forward for your feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for refreshing the branch, @im3dabasia!
The refactoring looks good, but it still needs some work.
- The
ToolsPanel
needsuseToolsPanelDropdownMenuProps
. - The
hasValue
conditions need to be fixed and correctly represent default values. Otherwise, the freshly inserted block already has values to reset. - The author selection isn't a block-level attribute, but modifies the actual post author; it would be difficult to define what default is and make it resettable. We might have to avoid using
ToolsPanelItem
for it. @t-hamano, had to make similar changes for a couple of other blocks, here's the recent one #70210.
Screenshot
Thanks for the follow-ups, @im3dabasia! I did a quick test, and I think we're moving in the right direction. I believe the last item from my previous comment still needs resolution - #67965 (review). |
Thank you for the feedbacks @Mamaduka . I think I have handled the last feedback as well, the suggestion was to remove Please Let me know if I am missing something. Author Selection Snippet without ToolsPanelItem
|
<ToolsPanelItem | ||
label={ __( 'Link author name' ) } | ||
isShownByDefault | ||
hasValue={ () => isLink !== false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasValue={ () => isLink !== false } | |
hasValue={ () => !! isLink } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@t-hamano , isLink
is by default false basis on the block.json, I was wondering if we could simply go for something like this
hasValue={ () => isLink }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no hard and fast rules, so I think either approach is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
All requested changes have been addressed.
) * refactor: Used ToolsPanel instead of PanelBody * feat: Remove ToolsPanel for the author selection control and added VStack for styling * feat: Add useToolsPanelDropdownMenuProps in the ToolsPanel as a prop * fix: Handle reset menu items properly in hasValue * fix: Improved code quality and showBio handling * chore: avatarSize code quality improvement * fix: Maintain consistency in label for Link Author Name * feat: Remove redudant CSS styles and file for editor.scss * fix: Update hasValue notations for the Avatar and Link controls * fix: Failing e2e, unit test cases due to wrong import Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Part of: #67813
Fixes: #67941
What?
Refactored Author Block code to include ToolsPanel instead of PanelBody.
Screenshots