Skip to content

Commit

Permalink
Use setTimeout hack (again) to get paste context in token search (#1548)
Browse files Browse the repository at this point in the history
* Use setTimeout hack (again) to get paste context in token search

* Update test

Co-authored-by: Esteban Miño <[email protected]>
  • Loading branch information
rickycodes and estebanmino authored May 12, 2020
1 parent 97a5ee3 commit b6cfb3b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
14 changes: 9 additions & 5 deletions app/components/UI/AssetSearch/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ exports[`AssetSearch should render correctly 1`] = `
placeholderTextColor="#d6d9dc"
rejectResponderTermination={true}
style={
Object {
"flex": 1,
"fontFamily": "CircularStd-Medium",
"fontWeight": "400",
}
Array [
Object {
"fontFamily": "CircularStd-Medium",
"fontWeight": "400",
},
Object {
"width": "85%",
},
]
}
testID="input-search-asset"
underlineColorAndroid="transparent"
Expand Down
12 changes: 8 additions & 4 deletions app/components/UI/AssetSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const styles = StyleSheet.create({
borderColor: colors.grey100
},
textInput: {
flex: 1,
...fontStyles.normal
},
icon: {
Expand Down Expand Up @@ -50,7 +49,8 @@ const fuse = new Fuse(contractList, {
*/
export default class AssetSearch extends PureComponent {
state = {
searchQuery: ''
searchQuery: '',
inputWidth: '85%'
};

static propTypes = {
Expand All @@ -60,6 +60,10 @@ export default class AssetSearch extends PureComponent {
onSearch: PropTypes.func
};

componentDidMount() {
setTimeout(() => this.setState({ inputWidth: '86%' }), 100);
}

handleSearch = searchQuery => {
this.setState({ searchQuery });
const fuseSearchResult = fuse.search(searchQuery);
Expand All @@ -71,13 +75,13 @@ export default class AssetSearch extends PureComponent {
};

render = () => {
const { searchQuery } = this.state;
const { searchQuery, inputWidth } = this.state;

return (
<View style={styles.searchSection} testID={'add-searched-token-screen'}>
<Icon name="search" size={22} style={styles.icon} />
<TextInput
style={styles.textInput}
style={[styles.textInput, { width: inputWidth }]}
value={searchQuery}
placeholder={strings('token.search_tokens_placeholder')}
placeholderTextColor={colors.grey100}
Expand Down

0 comments on commit b6cfb3b

Please sign in to comment.