Skip to content

Commit

Permalink
Changed selectedImage from index based to id based
Browse files Browse the repository at this point in the history
This helps keep the selection after reordering
  • Loading branch information
caxco93 committed Sep 30, 2018
1 parent fff6f87 commit f070faf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class GalleryEdit extends Component {
};
}

onSelectImage( index ) {
onSelectImage( imageId ) {
return () => {
if ( this.state.selectedImage !== index ) {
if ( this.state.selectedImage !== imageId ) {
this.setState( {
selectedImage: index,
selectedImage: imageId,
} );
}
};
Expand Down Expand Up @@ -272,10 +272,10 @@ class GalleryEdit extends Component {
alt={ img.alt }
id={ img.id }
dragId={ imageId }
isSelected={ isSelected && this.state.selectedImage === index }
isSelected={ isSelected && this.state.selectedImage === imageId }
index={ index }
onRemove={ this.onRemoveImage( index ) }
onSelect={ this.onSelectImage( index ) }
onSelect={ this.onSelectImage( imageId ) }
setAttributes={ ( attrs ) => this.setImageAttributes( index, attrs ) }
caption={ img.caption }
/>
Expand Down

0 comments on commit f070faf

Please sign in to comment.