Skip to content

Commit

Permalink
✨ Constrain on mount for defaultValue
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonJnsson committed Sep 20, 2021
1 parent ffc9682 commit 56af9b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions resources/js/support/filters/Search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import Filter from "@morningtrain/react-filters/Filter";
import Input from "@morningtrain/react-fields/simpletons/Input";
import { Env } from '@morningtrain/helpers'

export default class Search extends Filter {

Expand All @@ -11,6 +12,16 @@ export default class Search extends Filter {
};
}

componentDidMount () {
const {
defaultValue,
} = this.props

if (defaultValue) {
this.onSearch(defaultValue)
}
}

/////////////////////////////////
// Event handlers
/////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions resources/js/support/filters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { Injected as Echo } from './EchoFilter'
export { Injected as Env } from './EnvFilter'
export { Injected as ProjectCategory } from './project_category/ProjectCategoryFilter'
export { Injected as ResourceFilter } from './ResourceFilter'
export { Injected as Search } from './Search'

0 comments on commit 56af9b3

Please sign in to comment.