This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Trigger accounts/contracts search on search input change #2838
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e522ac2
Styling Chips in search bar (#2766)
ngotchac f44f0a3
Styling search chips // Add chip on space/comma/... (#2766)
ngotchac 5ae25d5
Update search on input (#2766)
ngotchac 78f234f
Fixing search triggers bugs (#2766)
ngotchac 957b834
removed console logs
ngotchac 4ae357d
Use props instead of weird CSS selectors for Search Bar
ngotchac cbd8df8
Add tags on space and commas in EditMeta modal (#2766)
ngotchac bc3319e
Fixed empty input in EditMeta modal ; tokens input
ngotchac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,10 @@ export default class ActionbarSearch extends Component { | |
if (tokens.length > 0 && this.props.tokens.length === 0) { | ||
this.handleOpenSearch(true, true); | ||
} | ||
|
||
if (tokens.length !== this.props.tokens.length) { | ||
this.handleSearchChange(tokens); | ||
} | ||
} | ||
|
||
componentWillUnmount () { | ||
|
@@ -127,10 +131,6 @@ export default class ActionbarSearch extends Component { | |
|
||
const newSearchTokens = uniq([].concat(tokens, value)); | ||
|
||
this.setState({ | ||
inputValue: '' | ||
}); | ||
|
||
this.handleSearchChange(newSearchTokens); | ||
} | ||
|
||
|
@@ -141,10 +141,6 @@ export default class ActionbarSearch extends Component { | |
.concat(tokens) | ||
.filter(v => v !== value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
|
||
this.setState({ | ||
inputValue: '' | ||
}); | ||
|
||
this.handleSearchChange(newSearchTokens); | ||
this.refs.searchInput.focus(); | ||
} | ||
|
@@ -154,27 +150,34 @@ export default class ActionbarSearch extends Component { | |
|
||
const inputValue = (splitTokens.length <= 1) | ||
? value | ||
: splitTokens.slice(-1)[0]; | ||
|
||
if (splitTokens.length > 1) { | ||
const tokensToAdd = splitTokens.slice(0, -1); | ||
tokensToAdd.forEach(token => this.handleTokenAdd(token)); | ||
} | ||
: splitTokens.slice(-1)[0].trim(); | ||
|
||
this.refs.searchInput.setState({ inputValue }); | ||
this.setState({ inputValue }); | ||
|
||
if (inputValue && inputValue.length > 0) { | ||
const { tokens, onChange } = this.props; | ||
onChange(tokens, [].concat(tokens, inputValue)); | ||
} | ||
this.setState({ inputValue }, () => { | ||
if (splitTokens.length > 1) { | ||
const tokensToAdd = splitTokens.slice(0, -1); | ||
tokensToAdd.forEach(token => this.handleTokenAdd(token)); | ||
} else { | ||
this.handleSearchChange(); | ||
} | ||
}); | ||
} | ||
|
||
handleSearchChange = (searchTokens) => { | ||
const { onChange } = this.props; | ||
const newSearchTokens = searchTokens.filter(v => v.length > 0); | ||
const { onChange, tokens } = this.props; | ||
const { inputValue } = this.state; | ||
|
||
const newSearchTokens = [] | ||
.concat(searchTokens || tokens) | ||
.filter(v => v.length > 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
const newSearchValues = [] | ||
.concat(searchTokens || tokens, inputValue) | ||
.filter(v => v.length > 0); | ||
|
||
console.log('handleSearchChange', newSearchTokens, newSearchValues); | ||
|
||
onChange(newSearchTokens, newSearchTokens); | ||
onChange(newSearchTokens, newSearchValues); | ||
} | ||
|
||
handleSearchClick = () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ class Accounts extends Component { | |
onAddSearchToken = (token) => { | ||
const { searchTokens } = this.state; | ||
const newSearchTokens = uniq([].concat(searchTokens, token)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
this.setState({ searchTokens: newSearchTokens }); | ||
this.setState({ searchTokens: newSearchTokens, searchValues: newSearchTokens }); | ||
} | ||
|
||
onNewAccountClick = () => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tokens.concat(value)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just in case tokens isn't really an
Array
, but I guess that's taken care of by thePropTypes
Object