File tree 3 files changed +12
-6
lines changed
packages/sanity/src/structure
3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,8 @@ export function PaneRouterProvider(props: {
149
149
ChildLink,
150
150
151
151
// Curried StateLink that pops off the last pane group
152
- BackLink,
152
+ // Only pass if this is not the first pane
153
+ BackLink : flatIndex ? BackLink : undefined ,
153
154
154
155
// A specialized `ChildLink` that takes in the needed props to open a
155
156
// referenced document to the right
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ export interface PaneRouterContextValue {
101
101
/**
102
102
* Curried StateLink that pops off the last pane group
103
103
*/
104
- BackLink : React . ComponentType < BackLinkProps >
104
+ BackLink ? : React . ComponentType < BackLinkProps >
105
105
106
106
/**
107
107
* A specialized `ChildLink` that takes in the needed props to open a
Original file line number Diff line number Diff line change @@ -78,11 +78,17 @@ export const DocumentPanelHeader = memo(
78
78
// and there is more than one split pane open (aka has-siblings)
79
79
const showSplitPaneCloseButton = showSplitPaneButton && hasGroupSiblings
80
80
81
+ // show the back button if both the feature is enabled and the current pane
82
+ // is not the first
83
+ const showBackButton = features . backButton && index > 0
84
+
81
85
// show the pane group close button if the `showSplitPaneCloseButton` is
82
86
// _not_ showing (the split pane button replaces the group close button)
83
87
// and if the back button is not showing (the back button and the close
84
- // button) do the same thing and shouldn't be shown at the same time)
85
- const showPaneGroupCloseButton = ! showSplitPaneCloseButton && ! features . backButton
88
+ // button do the same thing and shouldn't be shown at the same time)
89
+ // and if a BackLink component was provided
90
+ const showPaneGroupCloseButton = ! showSplitPaneCloseButton && ! showBackButton && ! ! BackLink
91
+
86
92
const { t} = useTranslation ( structureLocaleNamespace )
87
93
88
94
return (
@@ -95,8 +101,7 @@ export const DocumentPanelHeader = memo(
95
101
tabs = { showTabs && < DocumentHeaderTabs /> }
96
102
tabIndex = { tabIndex }
97
103
backButton = {
98
- features . backButton &&
99
- index > 0 && (
104
+ showBackButton && (
100
105
< Button
101
106
as = { BackLink }
102
107
data-as = "a"
You can’t perform that action at this time.
0 commit comments