Skip to content

Commit 9cf0ba6

Browse files
committed
Small fix for onChange event in RichText
1 parent 6728550 commit 9cf0ba6

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/controls/richText/RichText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ export class RichText extends React.Component<IRichTextProps, IRichTextState> {
760760
// do we need to pass this to a handler?
761761
if (onChange) {
762762
// yes, get the changed text from the handler
763-
let newText: string = this.props.onChange(value);
763+
let newText: string = onChange(value);
764764
this.setState({ text: newText });
765765
} else {
766766
// no, write the text to the state

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { Link } from 'office-ui-fabric-react/lib/components/Link';
4040
*/
4141
export default class ControlsTest extends React.Component<IControlsTestProps, IControlsTestState> {
4242
private taxService: SPTermStorePickerService = null;
43+
private richTextValue: string = null;
4344

4445
constructor(props: IControlsTestProps) {
4546
super(props);
@@ -53,7 +54,8 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
5354
authorEmails: [],
5455
selectedList: null,
5556
progressActions: this._initProgressActions(),
56-
dateTimeValue: new Date()
57+
dateTimeValue: new Date(),
58+
richTextValue: null
5759
};
5860

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

320-
<RichText isEditMode={this.props.displayMode === DisplayMode.Edit} />
322+
<RichText isEditMode={this.props.displayMode === DisplayMode.Edit} onChange={value => { this.richTextValue = value; return value; }} />
321323

322324
<ListItemAttachments listId='0ffa51d7-4ad1-4f04-8cfe-98209905d6da'
323325
itemId={1}

src/webparts/controlsTest/components/IControlsTestProps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ export interface IControlsTestState {
2222
progressActions: IProgressAction[];
2323
currentProgressActionIndex?: number;
2424
dateTimeValue: Date;
25+
richTextValue: string;
2526
}

0 commit comments

Comments
 (0)