Skip to content

Commit

Permalink
Taxonomy: Prefill new tag/category field if coming from search
Browse files Browse the repository at this point in the history
If a user searches for an existing tag/category within their taxonomy settings
then clicks "Add" to create the new taxonomy, we can prefill the new taxonomy
field with the search input.
  • Loading branch information
Jeremey committed Apr 27, 2017
1 parent c157707 commit ecaa345
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/blocks/taxonomy-manager/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class TaxonomyManager extends Component {
onClose={ this.closeTermFormDialog }
taxonomy={ this.props.taxonomy }
postType={ this.props.postType }
searchTerm={ search }
term={ this.state.selectedTerm }
showDescriptionInput
/>
Expand Down
8 changes: 8 additions & 0 deletions client/blocks/term-form-dialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TermFormDialog extends Component {
onClose: PropTypes.func,
onSuccess: PropTypes.func,
postType: PropTypes.string,
searchTerm: PropTypes.string,
showDescriptionInput: PropTypes.bool,
showDialog: PropTypes.bool,
siteId: PropTypes.number,
Expand Down Expand Up @@ -145,6 +146,13 @@ class TermFormDialog extends Component {

init( props ) {
if ( ! props.term ) {
if ( props.searchTerm && props.searchTerm.trim().length ) {
this.setState( assign( {}, this.constructor.initialState, {
name: props.searchTerm,
} ), this.isValid );
return;
}

this.setState( this.constructor.initialState );
return;
}
Expand Down

0 comments on commit ecaa345

Please sign in to comment.