fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

DocumentCard is using onClick handler to open URL.

Open lijunle opened this issue 9 years ago • 7 comments

Bug Report

  • Package version(s): all
  • Browser and OS versions: all

Priorities and help requested (not applicable if asking question):

Are you willing to submit a PR to fix? No

Requested priority: Normal

Describe the issue:

DocumentCard is using onClick event to open a URL. It is breaking in place navigation, accessibility, right-click context menu and a lot of stuff.

Expected behavior:

Render the URL as a <a href='xxx'> tag.

lijunle avatar Mar 10 '17 08:03 lijunle

@mikewheaton

dzearing avatar Mar 10 '17 16:03 dzearing

I created a PR for this but I don't think it's as simple as rendering an anchor tag due to the HTML spec and there already being anchors inside this element.

hross avatar Mar 11 '17 14:03 hross

Hi, @hross

It is not only to make it accessible. We find this issue because our in-place navigation (react-router) needs <a> tag for the magic. If it is JavaScript code to change window.location.href directly, it is not possible to get in-place navigation.

lijunle avatar Mar 14 '17 01:03 lijunle

Hi, @hross

I checked the document for <a> tag. It is allowing to contain the flow content. The <div> tag is one of flow content category.

That means, I think it is fine to wrap the whole DocumentCard component inside a <a> tag. However, I could step back and ask, why Fabric-React is going to integrate the click logic inside the DocumentCard component. Its parent is easy to control the logic correctly.

lijunle avatar Mar 15 '17 16:03 lijunle

Note that you cannot put <a>s inside other <a>s, which is an issue because the DocumentCard can contain other links. Inner links should be <a>s, but the outside container should be a <div> and it will unfortunately just have to manage middle clicks manually.

phkuo avatar Apr 11 '17 22:04 phkuo

@lijunle I am going to close this issue since there is a work around as @phkuo explained more elegantly than I did, the HTML spec doesn't allow for anchor tags inside of anchor tags :).

hross avatar Apr 12 '17 00:04 hross