-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Site Editor: make close button replaceable #22001
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||
/** | ||||||
* External dependencies | ||||||
*/ | ||||||
import { isEmpty } from 'lodash'; | ||||||
|
||||||
/** | ||||||
* WordPress dependencies | ||||||
*/ | ||||||
import { createSlotFill } from '@wordpress/components'; | ||||||
|
||||||
/** | ||||||
* Internal dependencies | ||||||
*/ | ||||||
import FullscreenModeClose from '../fullscreen-mode-close'; | ||||||
|
||||||
const { Fill: MainDashboardButton, Slot } = createSlotFill( | ||||||
'SiteEditorMainDashboardButton' | ||||||
); | ||||||
|
||||||
MainDashboardButton.Slot = () => ( | ||||||
<Slot> | ||||||
{ ( fills ) => { | ||||||
// Return default Close button if no fills are provided, otherwise replace it with available fills. | ||||||
if ( isEmpty( fills ) ) { | ||||||
return <FullscreenModeClose />; | ||||||
} | ||||||
|
||||||
return <> { fills } </>; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These spaces are significant, and cause React to create two additional text node children. https://codepen.io/aduth/pen/ZEbrOYY
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing it out! I removed this code in #22179. |
||||||
} } | ||||||
</Slot> | ||||||
); | ||||||
|
||||||
export default MainDashboardButton; |
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.
see #22027
We're moving away from regular slots. Would you mind doing a small refactor here (bubblesVirtually slots don't support children render function
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.
@youknowriad Actually I'm not sure how to achieve the same effect with this, given that it relies on children render function to handle the default case when no fills are provided?
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 examples of the same use-case in the code base. See here https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/block-inspector/index.js#L89-L90
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, refactored this in #22179.