Skip to content

Commit e965603

Browse files
authored
fix: Share split panel context between app instances (#3748)
1 parent 58f61d0 commit e965603

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/internal/context/split-panel-context.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import React, { createContext, useContext } from 'react';
3+
import React, { useContext } from 'react';
44

55
import { SplitPanelFocusControlRefs } from '../../app-layout/utils/use-split-panel-focus-control';
6+
import { awsuiPluginsInternal } from '../plugins/api';
67

78
export interface SplitPanelSideToggleProps {
89
displayed: boolean;
@@ -38,12 +39,16 @@ export interface SplitPanelContextProps extends SplitPanelContextBaseProps {
3839
animationDisabled?: boolean;
3940
}
4041

41-
const SplitPanelContext = createContext<SplitPanelContextProps | null>(null);
42+
const AppLayoutWidgetSplitPanelContext =
43+
awsuiPluginsInternal.sharedReactContexts.createContext<SplitPanelContextProps | null>(
44+
React,
45+
'AppLayoutWidgetSplitPanelContext'
46+
);
4247

43-
export const SplitPanelContextProvider = SplitPanelContext.Provider;
48+
export const SplitPanelContextProvider = AppLayoutWidgetSplitPanelContext.Provider;
4449

4550
export function useSplitPanelContext() {
46-
const ctx = useContext(SplitPanelContext);
51+
const ctx = useContext(AppLayoutWidgetSplitPanelContext);
4752
if (!ctx) {
4853
throw new Error('Split panel can only be used inside app layout');
4954
}

0 commit comments

Comments
 (0)