Skip to content

Commit

Permalink
Fix: Cover Block: Remove focal point attributes when they are not nee…
Browse files Browse the repository at this point in the history
…ded (#14746)

## Description
Currently, on the cover block, the focal points attributes are not unset even when they are not needed/used e.g: when the background is a video or when the background is fixed.

This makes the markup more complex with attributes that are irrelevant.

## How has this been tested?
Add a cover block with an image as background.
Change the focal points.
Enable the fixed background option.
Check on the code editor that there are no references to the focalPoint attribute.

Add a cover block with an image as background.
Enable the fixed background option.
Change the block to use a video background (using the media edit button + the media library).
Check on the code editor that there are no references to the hasParallax attribute.

Add a cover block with an image as background.
Change the focal points.
Change the block to use a video background (using the media edit button + the media library).
Check on the code editor that there are no references to the focalPoint attribute.
  • Loading branch information
jorgefilipecosta committed Apr 2, 2019
1 parent 70cc953 commit 6c9a9b2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,19 @@ class CoverEdit extends Component {
url: media.url,
id: media.id,
backgroundType: mediaType,
...( mediaType === VIDEO_BACKGROUND_TYPE ?
{ focalPoint: undefined, hasParallax: undefined } :
{}
),
} );
};

const toggleParallax = () => {
setAttributes( {
hasParallax: ! hasParallax,
...( ! hasParallax ? { focalPoint: undefined } : {} ),
} );
};
const toggleParallax = () => setAttributes( { hasParallax: ! hasParallax } );
const setDimRatio = ( ratio ) => setAttributes( { dimRatio: ratio } );

const style = {
Expand Down

0 comments on commit 6c9a9b2

Please sign in to comment.