Skip to content

Commit

Permalink
Image: Fix resetting behaviour for alt image text (#56809)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong authored Dec 6, 2023
1 parent 29e52a1 commit fceed16
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ export default function Image( {

const resetAll = () => {
setAttributes( {
alt: undefined,
width: undefined,
height: undefined,
scale: undefined,
Expand Down Expand Up @@ -456,14 +457,14 @@ export default function Image( {
<ToolsPanelItem
label={ __( 'Alternative text' ) }
isShownByDefault={ true }
hasValue={ () => alt !== '' }
hasValue={ () => !! alt }
onDeselect={ () =>
setAttributes( { alt: undefined } )
}
>
<TextareaControl
label={ __( 'Alternative text' ) }
value={ alt }
value={ alt || '' }
onChange={ updateAlt }
help={
<>
Expand All @@ -481,11 +482,13 @@ export default function Image( {
</ToolsPanelItem>
) }
{ isResizable && dimensionsControl }
<ResolutionTool
value={ sizeSlug }
onChange={ updateImage }
options={ imageSizeOptions }
/>
{ !! imageSizeOptions.length && (
<ResolutionTool
value={ sizeSlug }
onChange={ updateImage }
options={ imageSizeOptions }
/>
) }
{ showLightboxToggle && (
<ToolsPanelItem
hasValue={ () => !! lightbox }
Expand Down

1 comment on commit fceed16

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in fceed16.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7117143215
📝 Reported issues:

Please sign in to comment.