Skip to content

Commit

Permalink
Small fix for onChange event in RichText
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Apr 24, 2019
1 parent 6728550 commit 9cf0ba6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/controls/richText/RichText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ export class RichText extends React.Component<IRichTextProps, IRichTextState> {
// do we need to pass this to a handler?
if (onChange) {
// yes, get the changed text from the handler
let newText: string = this.props.onChange(value);
let newText: string = onChange(value);
this.setState({ text: newText });
} else {
// no, write the text to the state
Expand Down
6 changes: 4 additions & 2 deletions src/webparts/controlsTest/components/ControlsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { Link } from 'office-ui-fabric-react/lib/components/Link';
*/
export default class ControlsTest extends React.Component<IControlsTestProps, IControlsTestState> {
private taxService: SPTermStorePickerService = null;
private richTextValue: string = null;

constructor(props: IControlsTestProps) {
super(props);
Expand All @@ -53,7 +54,8 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
authorEmails: [],
selectedList: null,
progressActions: this._initProgressActions(),
dateTimeValue: new Date()
dateTimeValue: new Date(),
richTextValue: null
};

this._onIconSizeChange = this._onIconSizeChange.bind(this);
Expand Down Expand Up @@ -317,7 +319,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
<DateTimePicker label="DateTime Picker (unspecified = date and time)" value={new Date()} onChange={(value) => console.log("DateTimePicker value:", value)} />
<DateTimePicker label="DateTime Picker (unspecified = date and time)" timeConvention={TimeConvention.Hours24} value={new Date()} onChange={(value) => console.log("DateTimePicker value:", value)} />

<RichText isEditMode={this.props.displayMode === DisplayMode.Edit} />
<RichText isEditMode={this.props.displayMode === DisplayMode.Edit} onChange={value => { this.richTextValue = value; return value; }} />

<ListItemAttachments listId='0ffa51d7-4ad1-4f04-8cfe-98209905d6da'
itemId={1}
Expand Down
1 change: 1 addition & 0 deletions src/webparts/controlsTest/components/IControlsTestProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export interface IControlsTestState {
progressActions: IProgressAction[];
currentProgressActionIndex?: number;
dateTimeValue: Date;
richTextValue: string;
}

0 comments on commit 9cf0ba6

Please sign in to comment.