fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

DetailsList: right click on text link or title link of an item does not put item on selected state as expected

Open inateeg opened this issue 8 years ago • 11 comments

DetailsList: right click on text link or title link of an item does not put item on selected state as expected

  • any recent version__Package version(s)__: (fill this out)
  • Browser and OS versions: (fill this out if relevant)

Priorities and help requested:

Are you willing to submit a PR to fix? (Yes, No) yes if needed Requested priority: (Blocking, High, Normal, Low) High, blocking

Products/sites affected: (if applicable) SPO Items-View / ItemsScope webpart

Describe the issue:

ItemsScope/ItemsView is using DetailsList to render list view items. right click on the details row anywhere it would result in item row selected except that if right click on text Link element (title field), item is not being set as selected therefore context menu is all wrong.

Actual behavior:

item is not set as selected when right click on item's title/name link

Expected behavior:

Item is set as selected when right click on title as right click on any other place on the row.

If applicable, please provide a codepen repro:

https://odsp-int.azurewebsites.net/items-view/#component=id__9

or aks.ms/itemsview then navigate to ItemsView from left Nav under Component.

inateeg avatar Aug 08 '18 23:08 inateeg

This is likely due to <Link/> within the cell stopping the mouse event's propagation. I can repro with the implementation linked above and the advanced DetailsList example where some cells have hyperlinks.

If you're custom rendering cell contents then you can likely work around this by making sure the <Link/> component you use propagates the event to the DetailsList for selection or avoiding <Link/> for this cell content.

Any thoughts from the team re: supporting the above scenario cc: @cliffkoh @dzearing @natalieethell?

KevinTCoughlin avatar Aug 09 '18 00:08 KevinTCoughlin

@ThomasMichon I am not really sure about the right behavior here; I believe if you right click on a thing in a details row, in some cases you will want the link's default context menu. In the item-scope scenario, maybe you want the selected item context menu.

Originally I believe on right mouse down, we would switch selection early, so that in the case you wanted to provide your own row context menu, you would get the right selection. But maybe that changed to a later stage, causing this bug.

dzearing avatar Aug 09 '18 16:08 dzearing

In both itemsScope or odsp-next, we would want right click in a details list row anywhere behave the same. Not right click on text link behaves different than right click on other places in the row. That is what we try to get fix for?

From: David Zearing [email protected] Sent: Thursday, August 9, 2018 9:09 AM To: OfficeDev/office-ui-fabric-react [email protected] Cc: Ina Teegan [email protected]; Author [email protected] Subject: Re: [OfficeDev/office-ui-fabric-react] DetailsList: right click on text link or title link of an item does not put item on selected state as expected (#5865)

@ThomasMichonhttps://github.com/ThomasMichon I am not really sure about the right behavior here; I believe if you right click on a thing in a details row, in some cases you will want the link's default context menu. In the item-scope scenario, maybe you want the selected item context menu.

Originally I believe on right mouse down, we would switch selection early, so that in the case you wanted to provide your own row context menu, you would get the right selection. But maybe that changed to a later stage, causing this bug.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/OfficeDev/office-ui-fabric-react/issues/5865#issuecomment-411811450, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AT1rLptb9s0LRE46NMmW8R8twoGf0NHGks5uPF6CgaJpZM4V011_.

inateeg avatar Aug 09 '18 17:08 inateeg

it is true this column NameField is using element from fabric too. This means we still need to look into fabric here to ensure right click is propagated.

inateeg avatar Aug 09 '18 17:08 inateeg

What's odd to me is that I've used both <Link/> approaches: an <a/> and a <button/> depending if href is a fully formed combined with a ContextualMenu as seen in https://codepen.io/kevintcoughlin/pen/EpJaEq. But the selection problem doesn't occur as it does w/ ItemsScope.

I'm wondering if you're able to workaround it by invoking a selection method on the <List/> when that troublesome column is "clicked" to unblock yourselves cc: @ThomasMichon.

I'll keep trying to debug.

KevinTCoughlin avatar Aug 13 '18 22:08 KevinTCoughlin

I have tested a tentative fix by reset the selection inside the onContextMenu so that onMouseDown special case for A, button or link still takes effect as original fix intended but onContextMenu what is right click or dotdotdot ensure the current item is selected. Just tested and works as expected now. It is simple change and should I check it in or send the change to your OCE for checkin and potential patch to previous release?

From: Kevin Coughlin [email protected] Sent: Monday, August 13, 2018 3:21 PM To: OfficeDev/office-ui-fabric-react [email protected] Cc: Ina Teegan [email protected]; Author [email protected] Subject: Re: [OfficeDev/office-ui-fabric-react] DetailsList: right click on text link or title link of an item does not put item on selected state as expected (#5865)

What's odd to me is that I've used both approaches: an and a

@inateeg you can share a diff to the team and we can work to apply it or create a PR against this repo -- either work. We typically roll forward with patches tho so I'd target master.

KevinTCoughlin avatar Aug 13 '18 23:08 KevinTCoughlin

Done.

From: Kevin Coughlin [email protected] Sent: Monday, August 13, 2018 4:09 PM To: OfficeDev/office-ui-fabric-react [email protected] Cc: Ina Teegan [email protected]; Mention [email protected] Subject: Re: [OfficeDev/office-ui-fabric-react] DetailsList: right click on text link or title link of an item does not put item on selected state as expected (#5865)

@inateeghttps://github.com/inateeg you can share a diff to the team and we can work to apply it or create a PR against this repo -- either work. We typically roll forward with patches tho so I'd target master.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/OfficeDev/office-ui-fabric-react/issues/5865#issuecomment-412695937, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AT1rLsmi-btaWAFs37Tl3aHOyOqqg6Qoks5uQgb7gaJpZM4V011_.

inateeg avatar Aug 13 '18 23:08 inateeg

Sharing the diff... I'm continuing to work on this, but I don't believe the below one-line change can be merged into master as it double invokes the selection causing regressions in my local testing. Luckily this scenario involving a ContextualMenu seems to be isolated to DetailsList. I'm trying to see if we can get the desired behavior upstream to avoid regression.

The diff does help pinpoint where the fork in behavior is tho.

@@ -264,6 +264,9 @@ export class SelectionZone extends BaseComponent<ISelectionZoneProps, {}> {
 
       if (itemRoot) {
         const index = this._getItemIndex(itemRoot);
+
+        this._onInvokeMouseDown(ev, index);
+
         const skipPreventDefault = onItemContextMenu(selection.getItems()[index], index, ev.nativeEvent);
 
         // In order to keep back compat, if the value here is undefined, then we should still

https://github.com/OfficeDev/office-ui-fabric-react/blob/b057823de1ced6067fb123e6157aa916ae0f6221/packages/office-ui-fabric-react/src/utilities/selection/SelectionZone.tsx#L267

Will share updates as I have them.

KevinTCoughlin avatar Aug 14 '18 00:08 KevinTCoughlin

Hmm that is strange. I tested odsp-next seems working fine. If you look at function being called

private _onInvokeMouseDown( ev: React.MouseEvent | React.KeyboardEvent, index: number ): void { const { selection } = this.props;

// Only do work if item is not selected.
if (selection.isIndexSelected(index)) {
 return;
}

this._clearAndSelectIndex(index);

}

If current item is selected, return do nothing, where is the double selection from ?

From: Kevin Coughlin [email protected] Sent: Monday, August 13, 2018 5:02 PM To: OfficeDev/office-ui-fabric-react [email protected] Cc: Ina Teegan [email protected]; Mention [email protected] Subject: Re: [OfficeDev/office-ui-fabric-react] DetailsList: right click on text link or title link of an item does not put item on selected state as expected (#5865)

Sharing the diff... I'm continuing to work on this, but I don't believe the below one-line change can be merged into master as it double invokes the selection causing regressions in my local testing. Luckily this scenario involving a ContextualMenu seems to be isolated to DetailsList. I'm trying to see if we can get the desired behavior upstream to avoid regression.

The diff does help pinpoint where the fork in behavior is tho.

@@ -264,6 +264,9 @@ export class SelectionZone extends BaseComponent<ISelectionZoneProps, {}> {

   if (itemRoot) {

     const index = this._getItemIndex(itemRoot);

+

  •    this._onInvokeMouseDown(ev, index);
    

+

     const skipPreventDefault = onItemContextMenu(selection.getItems()[index], index, ev.nativeEvent);



     // In order to keep back compat, if the value here is undefined, then we should still

https://github.com/OfficeDev/office-ui-fabric-react/blob/b057823de1ced6067fb123e6157aa916ae0f6221/packages/office-ui-fabric-react/src/utilities/selection/SelectionZone.tsx#L267

Will share updates as I have them.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/OfficeDev/office-ui-fabric-react/issues/5865#issuecomment-412706567, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AT1rLgLS8Y0AbwmmJZp9-pYS3RiFzCouks5uQhN6gaJpZM4V011_.

inateeg avatar Aug 14 '18 00:08 inateeg

With the proposed change, right clicking on previously select-able column cells like the "Name" column in our DetailsList Advanced example no longer works. The previously selected item is re-selected.

ezgif-3-5bb559ca80

KevinTCoughlin avatar Aug 14 '18 00:08 KevinTCoughlin