From f23d53b29158834bd28906fab092c8a974d7401b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Thu, 4 Apr 2019 16:43:04 +0200 Subject: [PATCH 1/3] Rename method to better express intent --- packages/block-library/src/gallery/gallery-image.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/gallery/gallery-image.js b/packages/block-library/src/gallery/gallery-image.js index 1d4936d67e02b..1eca38de8cd91 100644 --- a/packages/block-library/src/gallery/gallery-image.js +++ b/packages/block-library/src/gallery/gallery-image.js @@ -18,7 +18,7 @@ class GalleryImage extends Component { constructor() { super( ...arguments ); - this.onImageClick = this.onImageClick.bind( this ); + this.onSelectImage = this.onSelectImage.bind( this ); this.onSelectCaption = this.onSelectCaption.bind( this ); this.onKeyDown = this.onKeyDown.bind( this ); this.bindContainer = this.bindContainer.bind( this ); @@ -44,7 +44,7 @@ class GalleryImage extends Component { } } - onImageClick() { + onSelectImage() { if ( ! this.props.isSelected ) { this.props.onSelect(); } @@ -108,9 +108,9 @@ class GalleryImage extends Component { src={ url } alt={ alt } data-id={ id } - onClick={ this.onImageClick } - onFocus={ this.onImageClick } - onKeyDown={ this.onImageClick } + onClick={ this.onSelectImage } + onFocus={ this.onSelectImage } + onKeyDown={ this.onSelectImage } tabIndex="0" aria-label={ ariaLabel } /> From c04f5e9b46ffe00483addfd3b962dac3b64266ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Thu, 4 Apr 2019 16:48:14 +0200 Subject: [PATCH 2/3] Fixes delete/backspace removes image from gallery --- packages/block-library/src/gallery/gallery-image.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/gallery/gallery-image.js b/packages/block-library/src/gallery/gallery-image.js index 1eca38de8cd91..f1bfec1cf03c2 100644 --- a/packages/block-library/src/gallery/gallery-image.js +++ b/packages/block-library/src/gallery/gallery-image.js @@ -20,7 +20,7 @@ class GalleryImage extends Component { this.onSelectImage = this.onSelectImage.bind( this ); this.onSelectCaption = this.onSelectCaption.bind( this ); - this.onKeyDown = this.onKeyDown.bind( this ); + this.onRemoveImage = this.onRemoveImage.bind( this ); this.bindContainer = this.bindContainer.bind( this ); this.state = { @@ -56,7 +56,7 @@ class GalleryImage extends Component { } } - onKeyDown( event ) { + onRemoveImage( event ) { if ( this.container === document.activeElement && this.props.isSelected && [ BACKSPACE, DELETE ].indexOf( event.keyCode ) !== -1 @@ -110,9 +110,10 @@ class GalleryImage extends Component { data-id={ id } onClick={ this.onSelectImage } onFocus={ this.onSelectImage } - onKeyDown={ this.onSelectImage } + onKeyDown={ this.onRemoveImage } tabIndex="0" aria-label={ ariaLabel } + ref={ this.bindContainer } /> { isBlobURL( url ) && } @@ -127,7 +128,7 @@ class GalleryImage extends Component { // Disable reason: Each block can be selected by clicking on it and we should keep the same saved markup /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */ return ( -
+
{ isSelected &&
Date: Fri, 5 Apr 2019 10:11:10 +0200 Subject: [PATCH 3/3] Remove no longer useful comment --- packages/block-library/src/gallery/gallery-image.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/block-library/src/gallery/gallery-image.js b/packages/block-library/src/gallery/gallery-image.js index f1bfec1cf03c2..9deae12a3ca02 100644 --- a/packages/block-library/src/gallery/gallery-image.js +++ b/packages/block-library/src/gallery/gallery-image.js @@ -125,8 +125,6 @@ class GalleryImage extends Component { 'is-transient': isBlobURL( url ), } ); - // Disable reason: Each block can be selected by clicking on it and we should keep the same saved markup - /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */ return (
{ isSelected && @@ -153,7 +151,6 @@ class GalleryImage extends Component { ) : null }
); - /* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */ } }