Skip to content

Commit

Permalink
Fix rich text e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Sep 26, 2019
1 parent f69af55 commit 1ab4854
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
4 changes: 4 additions & 0 deletions packages/e2e-tests/specs/rich-text.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
insertBlock,
clickBlockAppender,
pressKeyWithModifier,
pressKeyTimes,
} from '@wordpress/e2e-test-utils';

describe( 'RichText', () => {
Expand Down Expand Up @@ -83,10 +84,12 @@ describe( 'RichText', () => {
await page.mouse.move( 0, 0 );
await page.mouse.move( 10, 10 );
await page.click( '[aria-label="Bold"]' );
await pressKeyTimes( 'Tab', 5 );
await page.keyboard.type( 'bold' );
await page.mouse.move( 0, 0 );
await page.mouse.move( 10, 10 );
await page.click( '[aria-label="Bold"]' );
await pressKeyTimes( 'Tab', 5 );
await page.keyboard.type( '.' );

expect( await getEditedPostContent() ).toMatchSnapshot();
Expand Down Expand Up @@ -238,6 +241,7 @@ describe( 'RichText', () => {

it( 'should handle Home and End keys', async () => {
await page.keyboard.press( 'Enter' );
await page.evaluate( () => new Promise( window.requestAnimationFrame ) );

await pressKeyWithModifier( 'primary', 'b' );
await page.keyboard.type( '12' );
Expand Down
14 changes: 0 additions & 14 deletions packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,6 @@ class RichText extends Component {

this.recalculateBoundaryStyle();

// We know for certain that on focus, the old selection is invalid. It
// will be recalculated on the next mouseup, keyup, or touchend event.
const index = undefined;
const activeFormats = undefined;

this.record = {
...this.record,
start: index,
end: index,
activeFormats,
};
this.props.onSelectionChange( index, index );
this.setState( { activeFormats } );

// Update selection as soon as possible, which is at the next animation
// frame. The event listener for selection changes may be added too late
// at this point, but this focus event is still too early to calculate
Expand Down

0 comments on commit 1ab4854

Please sign in to comment.