Przeglądaj źródła

ensure to focus to input when TagEditor opened

Yuki Takei 7 lat temu
rodzic
commit
b848b0213c

+ 0 - 3
src/client/js/components/Page/TagEditor.jsx

@@ -24,9 +24,6 @@ class TagEditor extends React.Component {
     this.apiErrorHandler = this.apiErrorHandler.bind(this);
     this.apiErrorHandler = this.apiErrorHandler.bind(this);
   }
   }
 
 
-  async componentWillMount() {
-  }
-
   show(tags) {
   show(tags) {
     const isEditorMode = this.props.crowi.getCrowiForJquery().getCurrentEditorMode();
     const isEditorMode = this.props.crowi.getCrowiForJquery().getCurrentEditorMode();
     this.setState({ isOpenModal: true, isEditorMode, tags });
     this.setState({ isOpenModal: true, isEditorMode, tags });

+ 5 - 1
src/client/js/components/Page/TagsInput.jsx

@@ -29,6 +29,10 @@ export default class TagsInput extends React.Component {
     this.handleSelect = this.handleSelect.bind(this);
     this.handleSelect = this.handleSelect.bind(this);
   }
   }
 
 
+  componentDidMount() {
+    this.typeahead.getInstance().focus();
+  }
+
   handleChange(selected) {
   handleChange(selected) {
     // send tags to TagLabel Component when user add tag to form everytime
     // send tags to TagLabel Component when user add tag to form everytime
     this.setState({ selected }, () => {
     this.setState({ selected }, () => {
@@ -62,7 +66,7 @@ export default class TagsInput extends React.Component {
     return (
     return (
       <div className="tag-typeahead">
       <div className="tag-typeahead">
         <AsyncTypeahead
         <AsyncTypeahead
-          id="async-typeahead"
+          id="tag-typeahead-asynctypeahead"
           ref={(typeahead) => { this.typeahead = typeahead }}
           ref={(typeahead) => { this.typeahead = typeahead }}
           caseSensitive={false}
           caseSensitive={false}
           defaultSelected={this.state.defaultPageTags}
           defaultSelected={this.state.defaultPageTags}