Skip to content

Commit

Permalink
feat(structure): support closing first collapsed DocumentPanel (#5867)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdunk committed Feb 29, 2024
1 parent 84a0c90 commit 6d61e94
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ export function PaneRouterProvider(props: {
ChildLink,

// Curried StateLink that pops off the last pane group
BackLink,
// Only pass if this is not the first pane
BackLink: flatIndex ? BackLink : undefined,

// A specialized `ChildLink` that takes in the needed props to open a
// referenced document to the right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export interface PaneRouterContextValue {
/**
* Curried StateLink that pops off the last pane group
*/
BackLink: React.ComponentType<BackLinkProps>
BackLink?: React.ComponentType<BackLinkProps>

/**
* A specialized `ChildLink` that takes in the needed props to open a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ export const DocumentPanelHeader = memo(
// and there is more than one split pane open (aka has-siblings)
const showSplitPaneCloseButton = showSplitPaneButton && hasGroupSiblings

// show the back button if both the feature is enabled and the current pane
// is not the first
const showBackButton = features.backButton && index > 0

// show the pane group close button if the `showSplitPaneCloseButton` is
// _not_ showing (the split pane button replaces the group close button)
// and if the back button is not showing (the back button and the close
// button) do the same thing and shouldn't be shown at the same time)
const showPaneGroupCloseButton = !showSplitPaneCloseButton && !features.backButton
// button do the same thing and shouldn't be shown at the same time)
// and if a BackLink component was provided
const showPaneGroupCloseButton = !showSplitPaneCloseButton && !showBackButton && !!BackLink

const {t} = useTranslation(structureLocaleNamespace)

return (
Expand All @@ -95,8 +101,7 @@ export const DocumentPanelHeader = memo(
tabs={showTabs && <DocumentHeaderTabs />}
tabIndex={tabIndex}
backButton={
features.backButton &&
index > 0 && (
showBackButton && (
<Button
as={BackLink}
data-as="a"
Expand Down

0 comments on commit 6d61e94

Please sign in to comment.