Skip to content

Commit

Permalink
[field] PT: fix key issues
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin authored and rexxars committed Oct 6, 2020
1 parent 4aef323 commit 7550a39
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ export default function Annotation(props: Props) {
: () => {}

return (
<span
className={styles.root}
key={`annotation-${props.markDefKey}-${props.span._key}`}
onClick={handleClick}
>
<span className={styles.root} onClick={handleClick}>
{props.children}
</span>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function Block(props: Props): JSX.Element {
child.marks.filter(mark => isDecorator(mark, fromMap.schemaType as ObjectSchemaType)) || []
).map(mark => {
returned = (
<Decorator block={block} mark={mark} span={child}>
<Decorator key={`decorator-${child._key}-${mark}`} block={block} mark={mark} span={child}>
{returned}
</Decorator>
)
Expand All @@ -79,6 +79,7 @@ export default function Block(props: Props): JSX.Element {
returned = (
<Annotation
block={block}
key={`annotation-${child._key}-${markDefKey}`}
markDefKey={markDefKey}
onClick={handleObjectFocus}
span={child}
Expand All @@ -92,7 +93,7 @@ export default function Block(props: Props): JSX.Element {

const renderSpan = (props: {child: PortableTextChild; diff: ObjectDiff}): React.ReactNode => {
const {child, diff} = props
return <Span block={block} diff={diff} span={child} />
return <Span key={`span-${child._key}`} block={block} diff={diff} span={child} />
}

// Set up renderers for inline object types
Expand All @@ -102,7 +103,14 @@ export default function Block(props: Props): JSX.Element {
diff: ObjectDiff
}): React.ReactNode => {
const {child, diff} = props
return <InlineObject object={child} diff={diff} onClick={handleObjectFocus} />
return (
<InlineObject
key={`inline-object-${child._key}`}
object={child}
diff={diff}
onClick={handleObjectFocus}
/>
)
}
const renderInvalidInlineObjectType = () => {
return <span>Invalid inline object type</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Props = {
}
export default function Decorator(props: Props) {
return (
<span key={`decorator-${props.span._key}-${props.mark}`} className={`${styles[props.mark]}`}>
<span className={`${styles[props.mark]}`}>
{props.children}
</span>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ export default function Span(props: Props) {
returned = <AnnotatedStringDiff diff={textDiff} />
}
}
return <span key={`span-${span._key}`} className={styles.root}>{returned}</span>
return <span className={styles.root}>{returned}</span>
}

0 comments on commit 7550a39

Please sign in to comment.