Skip to content

Commit

Permalink
Keeping the visual and aural experiences the same
Browse files Browse the repository at this point in the history
Reviewed By: jessebeach

Differential Revision: D3232302

fb-gh-sync-id: 60cc28da92b34d14775b39532d491c0bc5ff6e02
fbshipit-source-id: 60cc28da92b34d14775b39532d491c0bc5ff6e02
  • Loading branch information
sota000 authored and Quentin Gérome committed Jun 9, 2016
1 parent cff28b8 commit 59fefc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions src/component/base/DraftEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,16 @@ class DraftEditor
};
}

_renderPlaceholder(): ?React.Element {
const content = this.props.editorState.getCurrentContent();
const showPlaceholder = (
this.props.placeholder &&
_showPlaceholder(): boolean {
return (
!!this.props.placeholder &&
!this.props.editorState.isInCompositionMode() &&
!content.hasText()
!this.props.editorState.getCurrentContent().hasText()
);
}

if (showPlaceholder) {
_renderPlaceholder(): ?React.Element {
if (this._showPlaceholder()) {
return (
<DraftEditorPlaceholder
text={nullthrows(this.props.placeholder)}
Expand Down Expand Up @@ -233,11 +234,6 @@ class DraftEditor
wordWrap: 'break-word',
};

let ariaDescribedBy = this.props.ariaDescribedBy;
if (ariaDescribedBy === undefined) {
ariaDescribedBy = this._placeholderAccessibilityID;
}

return (
<div className={rootClass}>
{this._renderPlaceholder()}
Expand All @@ -250,7 +246,9 @@ class DraftEditor
readOnly ? null : this.props.ariaActiveDescendantID
}
aria-autocomplete={readOnly ? null : this.props.ariaAutoComplete}
aria-describedby={ariaDescribedBy}
aria-describedby={
this._showPlaceholder() ? this._placeholderAccessibilityID : null
}
aria-expanded={readOnly ? null : this.props.ariaExpanded}
aria-haspopup={readOnly ? null : this.props.ariaHasPopup}
aria-label={this.props.ariaLabel}
Expand Down
2 changes: 1 addition & 1 deletion src/component/base/DraftEditorPlaceholder.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {DraftTextAlignment} from 'DraftTextAlignment';
import type EditorState from 'EditorState';

type Props = {
accessibilityID: ?string,
accessibilityID: string,
editorState: EditorState,
text: string,
textAlignment: DraftTextAlignment,
Expand Down

0 comments on commit 59fefc4

Please sign in to comment.