fix: fix issue where the title can be modified in read-only mode (#2761)

The title can be changed (but not saved) when the document is in read only mode.
This commit is contained in:
dkkb 2021-11-13 00:21:56 +08:00 committed by GitHub
parent a674a8668b
commit 94a2e453eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import styled from "styled-components";
type Props = {|
disabled?: boolean,
readOnly?: boolean,
onChange?: (text: string) => void,
onBlur?: (event: SyntheticInputEvent<>) => void,
onInput?: (event: SyntheticInputEvent<>) => void,
@ -33,6 +34,7 @@ function ContentEditable({
maxLength,
autoFocus,
placeholder,
readOnly,
...rest
}: Props) {
const ref = React.useRef<?HTMLSpanElement>();
@ -72,7 +74,7 @@ function ContentEditable({
return (
<div className={className}>
<Content
contentEditable={!disabled}
contentEditable={!disabled && !readOnly}
onInput={wrappedEvent(onInput)}
onBlur={wrappedEvent(onBlur)}
onKeyDown={wrappedEvent(onKeyDown)}