-
Notifications
You must be signed in to change notification settings - Fork 6
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
Extend Component class instead of using x-interaction #238
Conversation
2e92c17
to
83373a1
Compare
…term (defends against slow API response causing results to be shown when input is now empty).
This branch now includes cherry-pick of #241 |
if (targetIdIndex > -1) { | ||
followedTopicIds.splice(targetIdIndex, 1); | ||
handleInputClickOrFocus() { | ||
if (this.state.searchTerm.length >= this.minSearchLength) { |
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.
@dan-searle This line will prevent the bug which it displays results even if there is no searchTerm?
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.
Unfortunately not. This only happens when you click into the input. The bug happens when the input already has focus, a request has been made for suggestions, and the response arrives after the results container has been closed (because the input length < 2)
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.
I see. I know we are going to fix the bug after merging this PR, aren't we. Thank you!
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.
Yeah, the fix is the resultsForTerm
that's in various places.
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.
Actually, I had to revert that way of fixing it, as it didn't work very well. There's a different way of fixing it now.
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.
Looks good to me. Just a thought about the catch
block.
…he minSearchLength.
…ions with their follow buttons in the appropriate states.
881a6c4
to
80c2b45
Compare
x-interaction
unfortunately doesn't support ourx-topic-search
use case on the app, as it'll be re-rendered with any change in the followed topics array (on the MyFT -> Manage Topics page) and this causes us to run into #224.Using a Preact Component class allows the consumer to manage and pass-in the
followedTopicIds
as a prop.x-topic-search
holds in itsstate
the topics just searched, and can then render the correct result depending on thefollowedTopicIds
prop - e.g. present the search results, or show a "you already follow {topic}` message.This also allows us to nicely encapsulate the body event listeners required to close the topic search results when you click elsewhere on the page (#239).