Skip to content

Commit

Permalink
fix:changed value props to initialValue, to indicate the component is…
Browse files Browse the repository at this point in the history
… an uncontrolled component
  • Loading branch information
ogheneovo12 committed Dec 16, 2023
1 parent 17924d2 commit dd43130
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lib/components/DocumentEditor/document-editor.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const meta: Meta<typeof DocumentEditor> = {
title: 'DocumentEditor',
component: DocumentEditor,
args: {
value: initialEditorValue,
initialValue: initialEditorValue,
onChange: (val: Descendant[]) => console.log(val),
componentBlocks: {},
documentFeatures: defaultDocumentFeatures,
Expand All @@ -25,7 +25,7 @@ const Template: StoryFn<typeof DocumentEditor> = (args: DocumentEditorProps) =>
export const MainEditor = Template.bind({})
// More on args: https://storybook.js.org/docs/react/writing-stories/args
MainEditor.args = {
value: initialEditorValue,
initialValue: initialEditorValue,
onChange: (val: Descendant[]) => console.log(val),
componentBlocks: {},
documentFeatures: defaultDocumentFeatures,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/DocumentEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ export function createDocumentEditor(

export type DocumentEditorProps = {
onChange: undefined | ((value: Descendant[]) => void)
value: Descendant[]
initialValue: Descendant[]
componentBlocks: Record<string, ComponentBlock>
documentFeatures: DocumentFeatures
initialExpanded?: boolean
} & Omit<EditableProps, 'value' | 'onChange'>

export function DocumentEditor({
onChange,
value,
initialValue,
componentBlocks,
documentFeatures,
initialExpanded = false,
Expand All @@ -199,7 +199,7 @@ export function DocumentEditor({
componentBlocks={componentBlocks}
documentFeatures={documentFeatures}
editor={editor}
value={value}
value={initialValue}
onChange={(value) => {
onChange?.(value)
// this fixes a strange issue in Safari where the selection stays inside of the editor
Expand Down

0 comments on commit dd43130

Please sign in to comment.