mirror of
https://github.com/gosticks/react-table.git
synced 2026-08-16 23:10:17 +00:00
+20
-12
@@ -574,7 +574,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
||||
|
||||
const value = cellInfo.value
|
||||
|
||||
let interactionProps
|
||||
let useOnExpanderClick
|
||||
let isBranch
|
||||
let isPreview
|
||||
|
||||
@@ -626,17 +626,10 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
||||
if (cellInfo.pivoted || cellInfo.expander) {
|
||||
// Make it expandable by defualt
|
||||
cellInfo.expandable = true
|
||||
interactionProps = {
|
||||
onClick: onExpanderClick,
|
||||
}
|
||||
useOnExpanderClick = true
|
||||
// If pivoted, has no subRows, and does not have a subComponent, do not make expandable
|
||||
if (cellInfo.pivoted) {
|
||||
if (!cellInfo.subRows) {
|
||||
if (!SubComponent) {
|
||||
cellInfo.expandable = false
|
||||
interactionProps = {}
|
||||
}
|
||||
}
|
||||
if (cellInfo.pivoted && !cellInfo.subRows && !SubComponent) {
|
||||
cellInfo.expandable = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,6 +686,21 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
||||
}
|
||||
}
|
||||
|
||||
// If there are multiple onClick events, make sure they don't override eachother. This should maybe be expanded to handle all function attributes
|
||||
const interactionProps = {}
|
||||
|
||||
if (tdProps.rest.onClick) {
|
||||
interactionProps.onClick = e => {
|
||||
tdProps.rest.onClick(e, () => onExpanderClick(e))
|
||||
}
|
||||
}
|
||||
|
||||
if (columnProps.rest.onClick) {
|
||||
interactionProps.onClick = e => {
|
||||
columnProps.rest.onClick(e, () => onExpanderClick(e))
|
||||
}
|
||||
}
|
||||
|
||||
// Return the cell
|
||||
return (
|
||||
<TdComponent
|
||||
@@ -709,9 +717,9 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
||||
width: _.asPx(width),
|
||||
maxWidth: _.asPx(maxWidth),
|
||||
}}
|
||||
{...interactionProps}
|
||||
{...tdProps.rest}
|
||||
{...columnProps.rest}
|
||||
{...interactionProps}
|
||||
>
|
||||
{resolvedCell}
|
||||
</TdComponent>
|
||||
|
||||
+2
-2
@@ -145,7 +145,7 @@ function groupBy (xs, key) {
|
||||
|
||||
function asPx (value) {
|
||||
value = Number(value)
|
||||
return (Number.isNaN(value)) ? null : value + 'px'
|
||||
return Number.isNaN(value) ? null : value + 'px'
|
||||
}
|
||||
|
||||
function isArray (a) {
|
||||
@@ -179,7 +179,7 @@ function splitProps ({ className, style, ...rest }) {
|
||||
return {
|
||||
className,
|
||||
style,
|
||||
rest,
|
||||
rest: rest || {},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user