-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RichText: Fix browser formatting buttons #13833
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Component } from '@wordpress/element'; | ||
|
||
export class RichTextInputEvent extends Component { | ||
constructor() { | ||
super( ...arguments ); | ||
|
||
this.onInput = this.onInput.bind( this ); | ||
} | ||
|
||
onInput( event ) { | ||
if ( event.inputType === this.props.inputType ) { | ||
this.props.onInput(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a need to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's not really anything to prevent. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
And to that point, an |
||
} | ||
} | ||
|
||
componentWillMount() { | ||
ellatrix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
document.addEventListener( 'input', this.onInput, true ); | ||
} | ||
|
||
componentWillUnmount() { | ||
document.removeEventListener( 'input', this.onInput, true ); | ||
} | ||
|
||
render() { | ||
return null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A unit test for this component could be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would it work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this pseudocode:
I find these sorts of tests don't hurt and sometimes catch silly regressions e.g. typos.