fix(core): editor popover covered header popover (#4342)

This commit is contained in:
Joooye_34
2023-09-20 22:07:15 +08:00
committed by GitHub
parent 6e79858f41
commit 73f83cc97e
4 changed files with 34 additions and 8 deletions

View File

@@ -1,5 +1,14 @@
import { globalStyle, style } from '@vanilla-extract/css'; import { globalStyle, style } from '@vanilla-extract/css';
/**
* Editor container element layer should be lower than header and after auto
* The zIndex of header is 2, defined in apps/core/src/components/pure/header/style.css.tsx
*/
export const editorContainer = style({
position: 'relative',
zIndex: 0, // it will create stacking context to limit layer of child elements and be lower than after auto zIndex
});
export const pluginContainer = style({ export const pluginContainer = style({
height: '100%', height: '100%',
width: '100%', width: '100%',

View File

@@ -32,7 +32,7 @@ import { pageSettingFamily } from '../atoms';
import { fontStyleOptions, useAppSetting } from '../atoms/settings'; import { fontStyleOptions, useAppSetting } from '../atoms/settings';
import { BlockSuiteEditor as Editor } from './blocksuite/block-suite-editor'; import { BlockSuiteEditor as Editor } from './blocksuite/block-suite-editor';
import * as styles from './page-detail-editor.css'; import * as styles from './page-detail-editor.css';
import { pluginContainer } from './page-detail-editor.css'; import { editorContainer, pluginContainer } from './page-detail-editor.css';
import { TrashButtonGroup } from './pure/trash-button-group'; import { TrashButtonGroup } from './pure/trash-button-group';
export type OnLoadEditor = (page: Page, editor: EditorContainer) => () => void; export type OnLoadEditor = (page: Page, editor: EditorContainer) => () => void;
@@ -188,23 +188,27 @@ const PluginContentAdapter = memo<PluginContentAdapterProps>(
interface LayoutPanelProps { interface LayoutPanelProps {
node: LayoutNode; node: LayoutNode;
editorProps: PageDetailEditorProps; editorProps: PageDetailEditorProps;
depth: number;
} }
const LayoutPanel = memo(function LayoutPanel( const LayoutPanel = memo(function LayoutPanel(
props: LayoutPanelProps props: LayoutPanelProps
): ReactElement { ): ReactElement {
const node = props.node; const { node, depth, editorProps } = props;
const windowItems = useAtomValue(pluginWindowAtom); const windowItems = useAtomValue(pluginWindowAtom);
if (typeof node === 'string') { if (typeof node === 'string') {
if (node === 'editor') { if (node === 'editor') {
return <EditorWrapper {...props.editorProps} />; return <EditorWrapper {...editorProps} />;
} else { } else {
const windowItem = windowItems[node]; const windowItem = windowItems[node];
return <PluginContentAdapter pluginName={node} windowItem={windowItem} />; return <PluginContentAdapter pluginName={node} windowItem={windowItem} />;
} }
} else { } else {
return ( return (
<PanelGroup direction={node.direction}> <PanelGroup
direction={node.direction}
className={depth === 0 ? editorContainer : undefined}
>
<Panel <Panel
defaultSize={node.splitPercentage} defaultSize={node.splitPercentage}
style={{ style={{
@@ -212,7 +216,11 @@ const LayoutPanel = memo(function LayoutPanel(
}} }}
> >
<Suspense> <Suspense>
<LayoutPanel node={node.first} editorProps={props.editorProps} /> <LayoutPanel
node={node.first}
editorProps={editorProps}
depth={depth + 1}
/>
</Suspense> </Suspense>
</Panel> </Panel>
<PanelResizeHandle /> <PanelResizeHandle />
@@ -224,7 +232,11 @@ const LayoutPanel = memo(function LayoutPanel(
}} }}
> >
<Suspense> <Suspense>
<LayoutPanel node={node.second} editorProps={props.editorProps} /> <LayoutPanel
node={node.second}
editorProps={editorProps}
depth={depth + 1}
/>
</Suspense> </Suspense>
</Panel> </Panel>
</PanelGroup> </PanelGroup>
@@ -244,7 +256,7 @@ export const PageDetailEditor = (props: PageDetailEditorProps) => {
if (layout === 'editor') { if (layout === 'editor') {
return ( return (
<Suspense> <Suspense>
<PanelGroup direction="horizontal"> <PanelGroup direction="horizontal" className={editorContainer}>
<Panel> <Panel>
<EditorWrapper {...props} /> <EditorWrapper {...props} />
</Panel> </Panel>
@@ -256,7 +268,7 @@ export const PageDetailEditor = (props: PageDetailEditorProps) => {
return ( return (
<> <>
<Suspense> <Suspense>
<LayoutPanel node={layout} editorProps={props} /> <LayoutPanel node={layout} editorProps={props} depth={0} />
</Suspense> </Suspense>
</> </>
); );

View File

@@ -53,6 +53,10 @@ SettingPage.play = async ({ canvasElement, step }) => {
document.body.querySelector('[data-testid="language-menu-button"]') document.body.querySelector('[data-testid="language-menu-button"]')
); );
}); });
// Menu button may have "pointer-events: none" style, await 100ms to avoid this weird situation.
await new Promise(resolve => window.setTimeout(resolve, 100));
await step('click language menu button', async () => { await step('click language menu button', async () => {
await userEvent.click( await userEvent.click(
document.body.querySelector( document.body.querySelector(

View File

@@ -65,6 +65,7 @@ globalStyle(`html[data-theme="dark"] ${appStyle}`, {
export const mainContainerStyle = style({ export const mainContainerStyle = style({
position: 'relative', position: 'relative',
zIndex: 0, // it will create stacking context to limit layer of child elements and be lower than after auto zIndex
width: 0, width: 0,
flex: 1, flex: 1,
maxWidth: '100%', maxWidth: '100%',