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
Fix Token Reg Dapp issues in Firefox #4489
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -105,22 +105,22 @@ export default class InputText extends Component { | |
const { validationType, contract } = this.props; | ||
const validation = validate(value, validationType, contract); | ||
|
||
if (validation instanceof Promise) { | ||
const loadingTimeout = setTimeout(() => { | ||
this.setState({ disabled: true, loading: true }); | ||
}, 50); | ||
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. Doing this always feels very hacky, i.e. you are working around something you shouldn't be doing :) Only a mustn't-grumble. 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. Hmmm... It's more that it's not necessary to change the state twice if the request resolves in less than 50ms, no ? |
||
|
||
return validation | ||
.then(validation => { | ||
this.setValidation({ | ||
...validation, | ||
disabled: false, | ||
loading: false | ||
}); | ||
return Promise.resolve(validation) | ||
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. +1 |
||
.then((validation) => { | ||
clearTimeout(loadingTimeout); | ||
|
||
event.target.focus(); | ||
this.setValidation({ | ||
...validation, | ||
disabled: false, | ||
loading: false | ||
}); | ||
} | ||
|
||
this.setValidation(validation); | ||
event.target.focus(); | ||
}); | ||
} | ||
|
||
onKeyDown = (event) => { | ||
|
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 |
---|---|---|
|
@@ -49,7 +49,7 @@ | |
} | ||
|
||
.token-container { | ||
flex: 1; | ||
flex: 1 1 auto; | ||
} | ||
|
||
.full-width .token-container { | ||
|
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.
👍
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.
Yep, this wasn't working in Firefox...
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.
and we shouldn't do it anyway. there's
Promise.resolve
andnpm i is-promise
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.
why doesn't it work in firefox? it's valid JS isn't it?
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.
It doesn't work reliably with the
es6-promise
shim, which I'm guessing is included in FF. (Bluebird
has the same issue.)Chrome doesn't show it since it has native Promises.
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.
@gavofyork In JS, it is considered bad practice to assert
instanceof
in these cases. We only care about getting a thenable interface, whichPromise.resolve
should happily accept. See then/is-promise#6