Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use setTimeout hack (again) to get paste context in token search #1548

Merged
merged 3 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't 99% to 100% as all the other fixes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is the width just needs to be updated for it to work. In this case changing it from 99% to 100% pushed the magnifying glass out of the text box. Using these values brings the paste context back while ensuring things look proper.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool makes sense

}

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