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

fix: only show active router link styles on parent page #22069

Merged

Conversation

rachelruderman
Copy link
Contributor

@rachelruderman rachelruderman commented Jun 2, 2022

User facing changelog

Minor UI tweak to better indicate how to return to the Specs list when the test runner is active

Additional details

During the bug hunt, several Cypress employees on a video call could not see how to get back to the specs list from the runner, which is fair since the link that navigates there is active, so it is not styled to be clickable (other links have cursor: pointer and hover states, this does not, since we are already inside that part of the app).

This change makes it so the navigation links are only styled as active when the URL is an exact match. Now, if the user goes to a child page (i.e. test runner is a child page of the Specs page) the link to the parent page will appear clickable as it no longer has active styles.

Steps to test

  1. yarn dev
  2. Select "E2E testing"
  3. Confirm that the "Specs" nav link has active styles (purple color, default cursor on hover)
  4. Click on an E2E spec, i.e. logger.cy.ts
  5. Confirm that the "Specs" nav link no longer has active styles (gray color, pointer cursor on hover)
  6. Confirm that clicking the "Specs" nav link returns the user to the "Specs" parent page

How has the user experience changed?

Before:
Screen Shot 2022-06-02 at 4 45 10 PM

After:
Screen Shot 2022-06-02 at 4 45 28 PM

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 2, 2022

Thanks for taking the time to open a PR!

:active="isActive"
:active="isExactActive"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted for a global change instead of a Specs-only exception to ensure all navigation links continue to have the same behavior.

This means that if any of the other pages have links to a child view with a different URL (whether it be query params, pathname addition, etc) the navigation link will lose its active styles. This is intentional so that the user can more intuitively understand how to return to the parent page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree with doing this as the default. It's likely in the future, if we have nested router views, there would be cases where the exact route changes but the user is still "on" the main page. But I'm fine with not worrying about that till we get to that point.

@cypress
Copy link

cypress bot commented Jun 2, 2022



Test summary

37553 0 454 0Flakiness 5


Run details

Project cypress
Status Passed
Commit 934591e
Started Jun 3, 2022 4:44 PM
Ended Jun 3, 2022 5:00 PM
Duration 16:16 💡
OS Linux Debian - 10.11
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/actions/click.cy.js Flakiness
1 ... > scroll-behavior > can scroll to and click elements in html with scroll-behavior: smooth
2 ... > scroll-behavior > can scroll to and click elements in html with scroll-behavior: smooth
e2e/origin/commands/actions.cy.ts Flakiness
1 cy.origin actions > #consoleProps > .submit()
cypress/proxy-logging.cy.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second
2 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@rachelruderman rachelruderman changed the title use isExactActive fix: only show active router link styles on parent page Jun 2, 2022
cy.contains('.router-link-exact-active', 'Specs').should('not.exist')
cy.percySnapshot()

cy.get('a[href="#/specs"]').click()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to use a more specific selector like cy.findAllByTestId('nav-link-spec') just in case another link was added later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good call!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update looks elegant!

Copy link
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great and feels much more clear 👍

@rachelruderman rachelruderman merged commit 81f1b42 into develop Jun 3, 2022
@rachelruderman rachelruderman deleted the 21873/indicate-how-to-get-to-specs-from-runner branch June 3, 2022 18:45
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.

Indicate how to get to Specs Page from Runner (minor style tweaks to sidebar)
3 participants