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

tags header on sidebar #834

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

tags header on sidebar #834

wants to merge 1 commit into from

Conversation

daniel-owens
Copy link
Contributor

No description provided.

@@ -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}
Copy link
Member

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:

  1. 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.
  2. 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>}.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants