Skip to content

Commit 0b0a24d

Browse files
committed
Fix render crash on write page
1 parent a8b983f commit 0b0a24d

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

src/components/write/Toolbar.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ const ToolbarBlock = styled.div<{
2121
forMarkdown: boolean;
2222
}>`
2323
width: 100%;
24-
position: sticky;
2524
top: 0;
2625
display: flex;
2726
align-items: center;
2827
margin-bottom: 1rem;
29-
position: sticky;
3028
width: 100%;
3129
background: white;
3230
z-index: ${zIndexes.Toolbar};

src/components/write/WriteMarkdownEditor.tsx

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export interface MarkdownEditorProps {
3232
}
3333

3434
type MarkdownEditorState = {
35-
shadow: boolean;
3635
addLink: {
3736
top: number | null;
3837
bottom: number | null;
@@ -208,7 +207,7 @@ function WriterHead({
208207
children: React.ReactNode;
209208
}) {
210209
const screenHeight =
211-
(typeof window !== 'undefined' && window.screen.height) || 0;
210+
(typeof window !== 'undefined' && window.screen.height) || 508;
212211

213212
const springStyle = useSpring({
214213
maxHeight: hide ? 0 : screenHeight * 0.5,
@@ -233,7 +232,6 @@ export default class WriteMarkdownEditor extends React.Component<
233232
editorElement = React.createRef<HTMLTextAreaElement>();
234233
toolbarTop = 0;
235234
state = {
236-
shadow: false,
237235
addLink: {
238236
top: 0,
239237
bottom: 0,
@@ -333,25 +331,6 @@ export default class WriteMarkdownEditor extends React.Component<
333331
}
334332
};
335333

336-
handleScroll = (e: React.UIEvent<HTMLDivElement>) => {
337-
const { shadow } = this.state;
338-
const nextShadow = e.currentTarget.scrollTop > this.toolbarTop;
339-
// console.log(e.currentTarget.scrollTop, this.toolbarTop);
340-
if (shadow !== nextShadow) {
341-
this.setState({
342-
shadow: nextShadow,
343-
});
344-
}
345-
if (this.block.current) {
346-
const { clientWidth } = this.block.current;
347-
if (clientWidth !== this.state.clientWidth) {
348-
this.setState({
349-
clientWidth,
350-
});
351-
}
352-
}
353-
};
354-
355334
handleResize = () => {
356335
if (this.block.current) {
357336
this.setState({
@@ -810,14 +789,10 @@ ${selected}
810789
};
811790

812791
public render() {
813-
const { shadow, addLink, clientWidth } = this.state;
792+
const { addLink, clientWidth } = this.state;
814793
const { title, tagInput, footer } = this.props;
815794
return (
816-
<MarkdownEditorBlock
817-
ref={this.block}
818-
onScroll={this.handleScroll}
819-
data-testid="codemirror"
820-
>
795+
<MarkdownEditorBlock ref={this.block} data-testid="codemirror">
821796
<div className="wrapper">
822797
<WriterHead hide={this.state.hideUpper}>
823798
{ssrEnabled ? (
@@ -833,7 +808,7 @@ ${selected}
833808
{tagInput}
834809
</WriterHead>
835810
<Toolbar
836-
shadow={shadow || this.state.hideUpper}
811+
shadow={this.state.hideUpper}
837812
mode="MARKDOWN"
838813
onClick={this.handleToolbarClick}
839814
onConvert={this.handleAskConvert}

0 commit comments

Comments
 (0)