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

[Bug]: Table onRowClick with a table cell with link #458

Closed
2 tasks done
nichita-pasecinic opened this issue Nov 9, 2022 · 4 comments
Closed
2 tasks done

[Bug]: Table onRowClick with a table cell with link #458

nichita-pasecinic opened this issue Nov 9, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@nichita-pasecinic
Copy link

Browser

No response

Package version

^3.0.95

React version

^17.0.2

Description

Hi 👋 ,

I have a Table component with an onRowClick. The table has a cell that renders a Link component with an onFollow handler attached to it.

I need to trigger onRowClick only when user clicked on the cell, or outside cell, but it should NOT trigger when user clicked on the Link

event.preventDefault() from the onFollow does not help much.

Is that even possible ? (to have onFollow event to cancel onRowClick)

Thanks

Source code

No response

Reproduction

No response

Code of Conduct

@nichita-pasecinic nichita-pasecinic added the bug Something isn't working label Nov 9, 2022
@nichita-pasecinic
Copy link
Author

event.stopPropagation()

works as expected

@pan-kot
Copy link
Member

pan-kot commented Nov 10, 2022

Hello,

Please notice that our onRowClick API on the table is not recommended to use as a combination of clickable rows and clickable row elements results in a non-optimal user experience. Even if you can resolve the click handlers, the users might struggle to click the right thing.

I would recommend you to re-evaluate the need for onRowClick and try other options such as making table rows selectable and offering an action on the selected row(s) in the header.

Table API: https://cloudscape.design/components/table/?tabId=api

@nichita-pasecinic
Copy link
Author

Thanks @pan-kot,

From user perspective, isn't easier to just click on table row (an row item itself) and trigger the selection (to open the split panel) than finding the radio button (first column) to click on ?

I believe that is the approach used on several aws console tables.

Thanks!

@pan-kot
Copy link
Member

pan-kot commented Nov 10, 2022

It could be that for some experiences clicking on the row is easier. However, if, say, there are more clickable targets like links, or maybe you decide to make cell data editable inline - the clickable rows are no longer that great.

As a design system we try to come up with patterns that are consistent and reusable. It is true that some consoles might not yet have a chance to adopt those so the recommended approach here is to follow our guidance and demos.

Surely there is more than one way to make the users happy so if something works for you - that's great. We are happy to learn from your stories and improve!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants