-
Notifications
You must be signed in to change notification settings - Fork 22
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
tags header on sidebar #834
base: master
Are you sure you want to change the base?
Conversation
@@ -183,6 +183,9 @@ class ServicePage extends React.Component { | |||
</div> | |||
<div className="listing--aside"> | |||
<ActionSidebar resource={resource} service={service} /> | |||
{service.categories ? ( | |||
<p className="related-searches">Related Searches</p> | |||
) : null} |
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.
Thanks for submitting this! Two comments:
- You're failing the linter, which is complaining that you have trailing space characters at the end of this line. A good practice is to run the linter before you submit a PR so that you can correct the lint failures before having to wait for the automated tests to fail.
- For ternary operator expressions in JSX, if you're just returning a
null
in the "else" case, then it's better to just use the&&
operator, like{service.categories && <p className="related-searches">Related Searches</p>}
.
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.
Thank you for those tips! Duly noted.
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.
Richard, I'm worried about any unwanted negative consequences of that ternary operator. I didn't notice anything unusual when I was testing it out but it's ultimately going to affect the display of every listing that is clicked on. My thinking was that, if a listing contained indexes from the categories array then go ahead and display the header. Otherwise, don't list the header. It almost seemed to easy of a fix but perhaps that's all we need. I'm working on the rendering of this feature on smaller screens as well.
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.
@daniel-owens, I think the conditional logic is fine. I believe the intent of #807 is to affect the display of every listing, so it makes sense that this logic would affect all pages.
Looking at it more closely, however, I realized that we probably want to make a slight modification to the conditional. In JavaScript, an empty array still evaluates to true
, so what we really should do is use service.categories && service.categories.length != 0
to decide whether there are any categories.
No description provided.