Skip to content

Commit

Permalink
Editor: Avoid passing event object to save button onSave prop (#16770)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth authored Jul 29, 2019
1 parent 442ff9d commit fcbdd20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/editor/src/components/post-saved-state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class PostSavedState extends Component {
<IconButton
className="editor-post-save-draft"
label={ label }
onClick={ onSave }
onClick={ () => onSave() }
shortcut={ displayShortcut.primary( 's' ) }
icon="cloud-upload"
/>
Expand All @@ -113,7 +113,7 @@ export class PostSavedState extends Component {
return (
<Button
className="editor-post-save-draft"
onClick={ onSave }
onClick={ () => onSave() }
shortcut={ displayShortcut.primary( 's' ) }
isTertiary
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`PostSavedState should return Save button if edits to be saved 1`] = `
<ForwardRef(Button)
className="editor-post-save-draft"
isTertiary={true}
onClick={[MockFunction]}
onClick={[Function]}
shortcut="Ctrl+S"
>
Save Draft
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ describe( 'PostSavedState', () => {
);

expect( wrapper ).toMatchSnapshot();
wrapper.simulate( 'click' );
wrapper.simulate( 'click', {} );
expect( saveSpy ).toHaveBeenCalled();
// Regression: Verify the event object is not passed to prop callback.
expect( saveSpy.mock.calls[ 0 ] ).toEqual( [] );
} );
} );

0 comments on commit fcbdd20

Please sign in to comment.