Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions packages/module/src/DataViewTh/DataViewTh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
id: string | number | undefined,
width: number
) => void;
/** Width of the column */
/** Starting width in pixels of the column */
width?: number;
/** Minimum width of the column */
/** Minimum resize width in pixels of the column */
minWidth?: number;
/** Increment for keyboard navigation */
/** Increment in pixels for keyboard navigation */
increment?: number;
/** Increment for keyboard navigation while shift is held */
/** Increment in pixels for keyboard navigation while shift is held */
shiftIncrement?: number;
/** Provides an accessible name for the resizable column via a human readable string. */
resizeButtonAriaLabel?: string;
Expand Down Expand Up @@ -139,7 +139,7 @@
observer.unobserve(observed);
}
};
}, []);

Check warning on line 142 in packages/module/src/DataViewTh/DataViewTh.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

React Hook useEffect has a missing dependency: 'isResizable'. Either include it or remove the dependency array

useEffect(() => {
if ((isResizable || hasResizableColumns) && setInitialVals.current && width === 0) {
Expand Down Expand Up @@ -324,14 +324,22 @@
</Fragment>
);

const classNames: string[] = [];
if (thProps?.className) {
classNames.push(thProps.className);
}
if (dataViewThClassName) {
classNames.push(dataViewThClassName);
}

return (
<Th
modifier="truncate"
{...thProps}
{...props}
style={width > 0 ? { minWidth: width } : undefined}
ref={thRef}
modifier="truncate"
className={dataViewThClassName}
style={width > 0 ? { minWidth: width, ...thProps?.style } : thProps?.style}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume the minWidth here is important for the resizing feature. Is it possible that someone could inadvertently break the resize feature if they set thProps?.style? maybe the minWidth should be after the spreading of thProps.style so that the resize feature will keep working?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was debating that when I was reordering other props, and I'll go ahead and swap the order because the resize would break since a style prop would always override the internal minWidth. It should be uncommon for a user to directly modify minWidth via style since there are two width options in the props they can modify.

className={classNames.length > 0 ? classNames.join(' ') : undefined}
{...(isResizable && { additionalContent: resizableContent })}
>
{content}
Expand Down
Loading