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

ticket-charts: add smooth mode switch #1678

Merged
merged 6 commits into from
Feb 3, 2020

Conversation

njirap
Copy link
Contributor

@njirap njirap commented Jan 31, 2020

fixes #1502

tkt-smooth-mode

Screen Shot 2020-01-31 at 6 28 05 PM

Screen Shot 2020-01-31 at 6 28 15 PM

@njirap
Copy link
Contributor Author

njirap commented Jan 31, 2020

<li class="nav-item active">
<a
class="nav-link active"
href="javascript:void(0);"
Copy link
Member

@chappjc chappjc Jan 31, 2020

Choose a reason for hiding this comment

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

PR looks good, thanks.

@buck54321 I've wondered about the use of an anchor with the href javascript hack instead of a button. Thoughts about changing this?

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Accessibility

Anchor tags are often abused as fake buttons by setting their href to "#" or "javascript:void(0)" to prevent the page from refreshing, then listening for their click events .

These bogus href values cause unexpected behavior when copying/dragging links, opening links in a new tab/window, bookmarking, or when JavaScript is loading, errors, or is disabled. They also convey incorrect semantics to assistive technologies, like screen readers.

Use a <button> instead. In general, you should only use a hyperlink for navigation to a real URL.

But the inline javascript is what stands out to me as a potential challenge for deploying a good CSP.

Copy link
Member

Choose a reason for hiding this comment

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

I don't really understand why these are links at all. We should be applying the styling directly to the <li> elements, and making those elements the stimulus targets. This seems to be based on a pattern from the bootstrap docs. Interestingly, in the docs, they do use the anchor tag for the href.

@njirap, use href="#" for now in this PR. Another job might be to go through and remove all the links.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@chappjc chappjc Feb 1, 2020

Choose a reason for hiding this comment

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

Maybe with onclick? https://stackoverflow.com/a/1291944

If that doesn't work, we can stick with the javascript: until we can entirely nuke these anchors.

Copy link
Member

Choose a reason for hiding this comment

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

Using anchor tags is just an old convention since they automatically deal with small things like styling cursor hover and active state in a way that feels native to whatever client the end user is on.

Also if the application is using url backed state then its kind of semantic to use an anchor tag since the state change of clicking on it ( eg a query param to represent line mode) would get reflected in the url updating as well.

So I tend to just stick to using empty <a href=""> tags out of habit and simplicity.

But I think just using a utility class like .clickable { cursor: pointer; } and using any element that seems most semantic to handle clicks is just fine as well!

Just sharing my 2 cents here since I may have played a role in seeding this pattern in this repo. Don't have any qualms about moving away from the pattern if it feels wrong to folks.

Copy link
Member

Choose a reason for hiding this comment

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

Also if the application is using url backed state then its kind of semantic to use an anchor tag since the state change of clicking on it ( eg a query param to represent line mode) would get reflected in the url updating as well.

That's a good point about updating the URL, but I wouldn't find it odd for a button to do the same.

Copy link
Member

Choose a reason for hiding this comment

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

Now tracking this in issue #1679

Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

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

OK, we'll save the anchor javascript issue for another day. Anything else to add for this PR @buck54321 ?

<li class="nav-item">
<a
class="nav-link"
href="#"
Copy link
Member

Choose a reason for hiding this comment

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

Please revert this one back too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@chappjc chappjc merged commit 2dfb88a into decred:master Feb 3, 2020
@njirap njirap deleted the ticket-smooth-mode branch February 3, 2020 21:53
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.

ticket price chart smooth mode
4 participants