POC of honoring cmd+click events in cards to open card links in a new tab #7989
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Using an
href
property in an EuiCard will force the EuiCard to render the title as an anchor tag: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.
Here is a codesandbox example: https://c59jqv.csb.app/
This PR resolves this issue. However, I am not sure:
Opening this up for thoughts and feedback.
QA
Remove or strikethrough items that do not apply to your PR.
General checklist
@default
if default values are missing) and playground toggles