diff --git a/src/components/GlobalHeader/RightContent.tsx b/src/components/GlobalHeader/RightContent.tsx index 3516fc56..333d1b54 100644 --- a/src/components/GlobalHeader/RightContent.tsx +++ b/src/components/GlobalHeader/RightContent.tsx @@ -30,6 +30,7 @@ const GlobalHeaderRight: React.SFC = props => { placeholder={formatMessage({ id: 'component.globalHeader.search', })} + defaultValue="umi ui" dataSource={[ formatMessage({ id: 'component.globalHeader.search.example1', diff --git a/src/components/HeaderSearch/index.tsx b/src/components/HeaderSearch/index.tsx index 9e05b6af..85f8a387 100644 --- a/src/components/HeaderSearch/index.tsx +++ b/src/components/HeaderSearch/index.tsx @@ -17,10 +17,11 @@ export interface HeaderSearchProps { dataSource: DataSourceItemType[]; defaultOpen: boolean; open?: boolean; + defaultValue?: string; } interface HeaderSearchState { - value: string; + value?: string; searchMode: boolean; } @@ -52,7 +53,7 @@ export default class HeaderSearch extends Component { this.setState({ searchMode: false, - value: '', }); }; debouncePressEnter = () => { const { onPressEnter } = this.props; const { value } = this.state; - onPressEnter(value); + onPressEnter(value || ''); }; render() { - const { className, placeholder, open, ...restProps } = this.props; + const { className, defaultValue, placeholder, open, ...restProps } = this.props; const { searchMode, value } = this.state; delete restProps.defaultOpen; // for rc-select not affected const inputClass = classNames(styles.input, { @@ -134,6 +134,7 @@ export default class HeaderSearch extends Component { this.inputRef = node; }} + defaultValue={defaultValue} aria-label={placeholder} placeholder={placeholder} onKeyDown={this.onKeyDown}