Skip to content

Commit

Permalink
[components] Add missing array item key in template actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent 54f2fd4 commit dcdb636
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/@sanity/components/src/panes/DefaultPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const noop = () => {
const isActionButton = (item: MenuItemType) => Boolean(item.showAsAction)
const isMenuButton = negate(isActionButton)

class Pane extends React.PureComponent<DefaultPaneProps, State> {
class DefaultPane extends React.PureComponent<DefaultPaneProps, State> {
static defaultProps = {
index: 0,
footer: undefined,
Expand Down Expand Up @@ -180,7 +180,7 @@ class Pane extends React.PureComponent<DefaultPaneProps, State> {
)
}

renderActionMenuItem = (item: MenuItemType) => {
renderActionMenuItem = (item: MenuItemType, index: number) => {
if (!item) return null

const {styles = {}} = this.props
Expand All @@ -191,6 +191,7 @@ class Pane extends React.PureComponent<DefaultPaneProps, State> {
<IntentLink
className={styles.initialValueTemplateMenuItem}
intent="create"
key={item.key || index}
onClick={this.handleCloseTemplateMenu}
params={params}
>
Expand Down Expand Up @@ -253,7 +254,7 @@ class Pane extends React.PureComponent<DefaultPaneProps, State> {
}}
menu={
<div className={styles.initialValueTemplateMenu}>
{items.map(item => this.renderActionMenuItem(item))}
{items.map((item, index) => this.renderActionMenuItem(item, index))}
</div>
}
open={this.state.isInitialValueMenuOpen}
Expand Down Expand Up @@ -416,4 +417,4 @@ class Pane extends React.PureComponent<DefaultPaneProps, State> {
}
}

export default Styleable(Pane as any, defaultStyles) as React.ComponentType<DefaultPaneProps>
export default Styleable(DefaultPane as any, defaultStyles) as React.ComponentType<DefaultPaneProps>

0 comments on commit dcdb636

Please sign in to comment.