Skip to content

Commit

Permalink
fix: Remove usage of direct HTML access
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Jan 10, 2022
1 parent 8ec70b7 commit 64cffe6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/components/ContentEditable.tsx
Expand Up @@ -42,7 +42,7 @@ const ContentEditable = React.forwardRef(
) => {
const innerRef = React.useRef<HTMLSpanElement>(null);
const ref = forwardedRef || innerRef;
const [innerHTML, setInnerHTML] = React.useState<string>(value);
const [innerValue, setInnerValue] = React.useState<string>(value);
const lastValue = React.useRef("");

const wrappedEvent = (
Expand Down Expand Up @@ -75,7 +75,7 @@ const ContentEditable = React.forwardRef(

React.useEffect(() => {
if (value !== ref.current?.innerText) {
setInnerHTML(value);
setInnerValue(value);
}
}, [value, ref]);

Expand All @@ -88,12 +88,12 @@ const ContentEditable = React.forwardRef(
onBlur={wrappedEvent(onBlur)}
onKeyDown={wrappedEvent(onKeyDown)}
data-placeholder={placeholder}
suppressContentEditableWarning
role="textbox"
dangerouslySetInnerHTML={{
__html: innerHTML,
}}
{...rest}
/>
>
{innerValue}
</Content>
{children}
</div>
);
Expand Down

0 comments on commit 64cffe6

Please sign in to comment.