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

LB-947: Change entity pills on charts page from button to anchor #2672

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

piperswe
Copy link

Problem

https://tickets.metabrainz.org/browse/LB-947

Dipping my toes in, looking to contribute something to a project I've been loving lately!

Solution

I switched the element from a <button> to an <a>, and also added href properties to their usage in UserEntityChart. It defaults to # as a hash to preserve the pointer cursor, and for accessibility reasons. Changed validated locally - URL appears in status bar and open-in-new-tab (both middle click and right click -> open in new tab) seems to work fine. I integrated the proposed fix in LB-925, so ctrl/cmd+click also work.

Open question: should it only be an <a> if the href property is set? Semantically, <button> makes sense in several of the other places Pill is used. Not sure how much it matters though.

@@ -239,7 +244,7 @@ export default class UserEntityChart extends React.Component<
count: elem.listen_count,
caaID: elem.caa_id,
caaReleaseMBID: elem.caa_release_mbid,
artists: elem.artists
artists: elem.artists,
Copy link
Author

@piperswe piperswe Dec 14, 2023

Choose a reason for hiding this comment

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

this change was made by prettier, looks like there are a few outstanding lint issues? the dev environment automatically runs prettier, so there's no good way to get around including this diff in the PR without messing with Git hunks

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't worry about these extra linting changes, indeed we merged some un-linted changes in master.

Copy link
Contributor

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

Thank you for opening this PR, and welcome ! :)

I've got a suggestion below to apply this fix more generally:

Comment on lines +518 to +523
onClick={(e) => {
// LB-925 ctrl-click and cmd-click shouldn't navigate in this tab
if (!e.ctrlKey) {
e.preventDefault();
this.changeEntity("release-group");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this mechanism should directly be implemented in the Pill component rather than only for this page, so that navigation is consistent across our different pages that use this Pill.

We would have something like this in Pill:

const {onClick} = props;
const customOnClick = (e) => {
  if (!e.ctrlKey) {
    e.preventDefault();
    onClick();
  }
}
…
<a onClick={customOnClick} …>

@@ -239,7 +244,7 @@ export default class UserEntityChart extends React.Component<
count: elem.listen_count,
caaID: elem.caa_id,
caaReleaseMBID: elem.caa_release_mbid,
artists: elem.artists
artists: elem.artists,
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't worry about these extra linting changes, indeed we merged some un-linted changes in master.

@MonkeyDo
Copy link
Contributor

MonkeyDo commented Jan 3, 2024

should it only be an if the href property is set? Semantically, makes sense in several of the other places Pill is used. Not sure how much it matters though.

A good question. I think the answer for now is "don't worry about it", as we started talking about moving to a single page application which would change the way we handle navigation.

@MonkeyDo
Copy link
Contributor

MonkeyDo commented Jan 3, 2024

I had to manually accept for our CI build to be run, and now that that is done there are a few failing tests regarding this change from button to anchor.

Let me know if you need anything !

@MonkeyDo
Copy link
Contributor

MonkeyDo commented Feb 7, 2024

Hi @piperswe !
Let me know if you have any time to finish this PR up.
No pressure; if you would rather pass the baton on to someone else that's also fine, just let us know :)

@MonkeyDo
Copy link
Contributor

@piperswe Ping!
Hello, checking in to see if I should take over this PR or if you'd like to finish it. Please let me know!

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