Skip to content

fix: Wrap TableCell with Link for native browser routing #2532

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

Merged
merged 1 commit into from
Jun 21, 2022
Merged

Conversation

kylecarbs
Copy link
Member

Tables were previously using an onClick handler which replicated some
Link behavior, but not natively through the browser.

Fixes #2525.

@kylecarbs kylecarbs self-assigned this Jun 20, 2022

const useStyles = makeStyles((theme) => ({
cell: {
padding: "0 !important",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need !important in these styles?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the MUI styles will override, and that can't work for the padding (because this needs to fill the entire cell).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I wonder if we could use specificity in class naming to get around this. Not a blocker for this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shall try!

Comment on lines -110 to -111
cursor: "pointer",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?: why are we removing this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pointer still exists, it's just provided by the "a" tag now!

import { combineClasses } from "../../util/combineClasses"

// TableCellLink wraps a TableCell filling the entirety with a Link.
// This allows table rows to be clickable with browser-behavior like ctrl+click.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Copy link
Contributor

@AbhineetJain AbhineetJain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making a TableRowLink instead? 🤔 Do we have independent usages for a TableCellLink?

background: "none",
paddingTop: theme.spacing(2),
paddingBottom: theme.spacing(2),
textDecoration: "none !important",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!important generally is not a good pattern. I wonder if there's a way around this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get more specific with a selector?

@kylecarbs
Copy link
Member Author

@AbhineetJain it's not possible to wrap an entire row, only particular cells. I wish!

@kylecarbs kylecarbs marked this pull request as ready for review June 21, 2022 14:42
@kylecarbs kylecarbs requested a review from a team as a code owner June 21, 2022 14:42

const useStyles = makeStyles((theme) => ({
cell: {
"&.MuiTableCell-root:not(:only-child):first-child, &.MuiTableCell-root:not(:only-child):last-child": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

Tables were previously using an onClick handler which replicated some
Link behavior, but not natively through the browser.

Fixes #2525.
@kylecarbs kylecarbs enabled auto-merge (squash) June 21, 2022 16:29
@kylecarbs kylecarbs merged commit a48a838 into main Jun 21, 2022
@kylecarbs kylecarbs deleted the clicklink branch June 21, 2022 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: new tab click idioms don't work on workspace, workspaces, and templates page page
4 participants