mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 12:23:08 +08:00
Mention in controlled mode suggestions bug fix (#4718)
* Mention in controlled mode suggestions bug fix + close #4716
This commit is contained in:
parent
340385d34d
commit
e270fa87af
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import RcMention, { Nav, toString, toEditorState, getMentions } from 'rc-editor-mention';
|
||||
import classNames from 'classnames';
|
||||
import shallowequal from 'shallowequal';
|
||||
import Icon from '../icon';
|
||||
|
||||
export interface MentionProps {
|
||||
@ -47,10 +48,12 @@ export default class Mention extends React.Component<MentionProps, MentionState>
|
||||
};
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
this.setState({
|
||||
suggestions: nextProps.suggestions,
|
||||
});
|
||||
componentWillReceiveProps({ suggestions }) {
|
||||
if (!shallowequal(suggestions, this.props.suggestions)) {
|
||||
this.setState({
|
||||
suggestions,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onSearchChange = (value) => {
|
||||
@ -75,6 +78,7 @@ export default class Mention extends React.Component<MentionProps, MentionState>
|
||||
suggestions: filteredSuggestions,
|
||||
});
|
||||
}
|
||||
|
||||
onFocus = (ev) => {
|
||||
this.setState({
|
||||
focus: true,
|
||||
|
Loading…
Reference in New Issue
Block a user