Skip to content

Commit

Permalink
FIX - Cannot type in the Link Input dialog when in a paragraph (#3468)
Browse files Browse the repository at this point in the history
  • Loading branch information
tg-ephox authored and youknowriad committed Nov 14, 2017
1 parent 42f6d02 commit 0aee803
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/slot-fill/fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ class Fill extends Component {
}
}

componentDidUpdate() {
const { getSlot = noop } = this.context;
const slot = getSlot( this.props.name );
if ( slot && ! slot.props.bubblesVirtually ) {
slot.forceUpdate();
}
}

render() {
const { getSlot = noop } = this.context;
const { name, children } = this.props;
Expand Down
36 changes: 36 additions & 0 deletions components/slot-fill/test/slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ import Slot from '../slot';
import Fill from '../fill';
import Provider from '../provider';

/**
* WordPress Dependencies
*/
import { Component } from '@wordpress/element';

class Filler extends Component {
constructor() {
super( ...arguments );

this.state = {
num: 1,
};
}
render() {
return [
<button key="1" type="button" onClick={ () => this.setState( { num: this.state.num + 1 } ) } />,
<Fill name={ this.props.name } key="2">{ this.state.num.toString() }</Fill>,
];
}
}

describe( 'Slot', () => {
it( 'should render empty Fills', () => {
const element = mount(
Expand Down Expand Up @@ -60,4 +81,19 @@ describe( 'Slot', () => {

expect( element.find( 'Slot > div' ).html() ).toBe( '<div><span></span><div></div>text</div>' );
} );

it( 'should re-render Slot when not bubbling virtually', () => {
const element = mount(
<Provider>
<Slot name="egg" />
<Filler name="egg" />
</Provider>
);

expect( element.find( 'Slot > div' ).html() ).toBe( '<div>1</div>' );

element.find( 'button' ).simulate( 'click' );

expect( element.find( 'Slot > div' ).html() ).toBe( '<div>2</div>' );
} );
} );

0 comments on commit 0aee803

Please sign in to comment.