-
Notifications
You must be signed in to change notification settings - Fork 888
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
Conversation
|
||
const useStyles = makeStyles((theme) => ({ | ||
cell: { | ||
padding: "0 !important", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I shall try!
cursor: "pointer", | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
There was a problem hiding this 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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
@AbhineetJain it's not possible to wrap an entire row, only particular cells. I wish! |
|
||
const useStyles = makeStyles((theme) => ({ | ||
cell: { | ||
"&.MuiTableCell-root:not(:only-child):first-child, &.MuiTableCell-root:not(:only-child):last-child": { |
There was a problem hiding this comment.
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.
Tables were previously using an onClick handler which replicated some
Link behavior, but not natively through the browser.
Fixes #2525.