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

POC of honoring cmd+click events in cards to open card links in a new tab #7989

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JasonStoltz
Copy link
Member

@JasonStoltz JasonStoltz commented Aug 28, 2024

Summary

Using an href property in an EuiCard will force the EuiCard to render the title as an anchor tag:

Screenshot 2024-08-28 at 1 16 49 PM

Logic for this is here.

Clicking on the title of a card using href works like any other link. Nothing special here.

However, when passing an href to a card, the expectation is that the entire card is a clickable link, not just the title. For that reason, we add an additional click handler to the entire card, which will manually trigger an click event on our title anchor if anywhere other than the title anchor is clicked.

So basically, if someone clicks on on a card anywhere other than the title, we're going to pretend that they actually clicked on the title, and manually simulate that click event.

That logic is here.

The problem with this, is that many folks use cmd+click in order to open links in a new tab. This does work when clicking directly on the title link, but does not work when clicking anywhere else on the card.

Screenshot 2024-08-28 at 1 26 03 PM

Here is a codesandbox example: https://c59jqv.csb.app/

This PR resolves this issue. However, I am not sure:

  1. How it works cross-browser
  2. If it's OK to manually force a PointerEvent (what if the original event was a MouseEvent?)

Opening this up for thoughts and feedback.

QA

Remove or strikethrough items that do not apply to your PR.

General checklist

  • Browser QA
    • Checked in both light and dark modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
    • Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
    • If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist
    • If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)

@JasonStoltz
Copy link
Member Author

Apparently this is a community submitted PR.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Aug 28, 2024

💔 Build Failed

Failed CI Steps

History

@elastic elastic deleted a comment from github-actions bot Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants