UserItem: Clean up onPress logic a bit#4429
Merged
chrisbobbe merged 3 commits intozulip:masterfrom Jan 22, 2021
Merged
Conversation
This is pretty dubious logic that, to the extent it's possible for it to have any effect at all, makes this component's interface more complicated than it needs to be. Happily, this condition should never be able to trigger: * Most callers of `UserItemRaw` get here through `UserItem`, which looks up a real user's data. Real users don't have the empty string (let alone some other falsy value, which wouldn't be well-typed) as their "email". * The one other caller is `PeopleAutocomplete`. That one passes a number of real users, and possibly a couple of pseudo-users generated by `getAutocompleteSuggestion`. Those two pseudo-users have non-empty "emails" too: they both read "(Notify everyone)". So nothing could have been relying on this quirk, and we can just cut it out.
Sometimes there's nothing the surrounding UI actually wants to have happen if the user presses the UserItem. In that case we can simplify by not making the caller pass in a do-nothing onPress callback.
When there's no `onPress` callback passed in to this component, our own `handlePress` will do nothing. Rather than pass that on down as an `onPress` prop, pass nothing again. This is useful because when our `Touchable` doesn't receive an actual callback for interaction, it can avoid creating an underlying `TouchableHighlight` or `TouchableNativeFeedback` at all, and so avoid falsely advertising to a screen reader or other a11y interface that there's some interaction being offered here.
Contributor
|
LGTM, merged! Thanks. |
Member
Author
|
Thanks for the fast review and merge 😄 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a quick followup to #4424, to make the cleanups discussed at #4424 (comment) .