Page MenuHomePhabricator

Badge cards that use `PHUIBadgeView` should not flip the card if a link on the card is clicked
Closed, ResolvedPublic

Description

PHUIBadgeView is used for badge cards, where the card flips over if a user clicks on it. Currently, the click listener flips the card over not matter what. If the click came from a link click on the card, the card should not flip over.

Original discussion in D15570:

For the clicking thing, I think we have to write custom JS. Currently, it's powered by a simple behavior (jx-toggle-class) in PHUIBadgeView, which just says "toggle this CSS class on/off when the thing is clicked".

There's no way to make this behavior more complex/subtle (e.g., ignore clicks on links) and it's important that it not ignore clicks on links in all cases because it also powers stuff like "Show/Hide Details" links elsewhere.

So this probably boils down to:

  • Write a new behavior which does the toggling.
  • It can mostly work like jx-toggle-class, but can probably be a bit simpler since it's custom.
  • It should ignore clicks on links inside the card.

This seems fine to push to a future diff to me.

To check if something is a click on a link, you'll do something like this:

JX.Stratcom.listen('badge-view', 'click', function(e) {
  if (e.getNode('tag:a')) {
     // If the event has a 'tag:a' node on it, that means the user
     // either clicked a link or some other node inside a link.
     return;
   }
   // ...
 });