Skip to content

Commit

Permalink
Prevent unwanted 'flash' of 'expanded' button
Browse files Browse the repository at this point in the history
It's necessary to manually toggle 'isDefaultView' off to prevent a 'flash' of the 'expanded' default button displaying when a replaceable block is deselected.
  • Loading branch information
Siobhan committed Apr 10, 2022
1 parent fd73fa6 commit db5d32e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/block-editor/src/components/inserter/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
insertBefore,
} from '@wordpress/icons';
import { setBlockTypeImpressions } from '@wordpress/react-native-bridge';
import { store as editPostStore } from '@wordpress/edit-post';

/**
* Internal dependencies
Expand Down Expand Up @@ -175,7 +176,20 @@ export class Inserter extends Component {
}

onToggle( isOpen ) {
const { blockTypeImpressions, onToggle, updateSettings } = this.props;
const {
blockTypeImpressions,
onToggle,
updateSettings,
toggleFeature,
} = this.props;
const { shouldReplaceBlock } = this.state;

// It's necessary to manually toggle 'isDefaultView' off to prevent
// a 'flash' of the 'expanded' default button displaying when a
// replaceable block is deselected.
if ( shouldReplaceBlock ) {
toggleFeature( 'isDefaultView' );
}

if ( ! isOpen ) {
const impressionsRemain = Object.values(
Expand Down Expand Up @@ -358,7 +372,8 @@ export class Inserter extends Component {
export default compose( [
withDispatch( ( dispatch ) => {
const { updateSettings } = dispatch( blockEditorStore );
return { updateSettings };
const { toggleFeature } = dispatch( editPostStore );
return { updateSettings, toggleFeature };
} ),
withSelect( ( select, { clientId, isAppender, rootClientId } ) => {
const {
Expand Down

0 comments on commit db5d32e

Please sign in to comment.