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
Improve step by step component double dot problem solving code #473
Improve step by step component double dot problem solving code #473
Conversation
5fcb418
to
f659fac
Compare
f659fac
to
e1ae137
Compare
e1ae137
to
75164f9
Compare
|
||
The current page in the step by step navigation is an anchor link to the top of the page. If there are more than one of these and the user clicks one that is not currently highlighted, that one will be highlighted. | ||
If a user has not clicked a link (i.e. has visited the page without first clicking on a step by step navigation) only the first duplicate link will be highlighted. If that link is not in the active step, the JS makes the highlighted link's parent the active step. If there is no active step, the first active link will be highlighted (but there should always be an active step). |
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.
If that link is not in the active step, the JS makes the highlighted link’s parent the active step
How would this be possible?
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.
The code basically goes...
if we've got the same link twice in the component
AND
there's nothing in the session to tell us which link to highlight
AND
the first highlighted link is not in the active step
THEN
change the active step to be the one that the first highlighted link is in
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.
It's the thing I was talking about where the frontend code no longer trusts the backend to be right about which step should be highlighted and expanded, and takes matters into its own hands.
75164f9
to
92d856d
Compare
92d856d
to
47cd87e
Compare
|
||
if (lastClicked) { |
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.
should you keep this in? What would happen if the active class couldn't be found either?
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.
If the active class isn't found then this entire function has already exited on line 231. The rest only gets called if there's more than one active class found.
Other than that one comment, it looks good 👍 |
- shorten - if no sessionStorage value (i.e. user is arriving at the page cold) highlight the first active link and active step, not the last - expand documentation to clarify how this behaves
47cd87e
to
45b1124
Compare
See the documentation for full details. Expands the solution to this problem:
Trello card: https://trello.com/c/LTzIkmOX/776-optimise-default-open-step
Component guide for this PR:
https://govuk-publishing-compon-pr-473.herokuapp.com/component-guide/