gregnb / gregnb/mui-datatables

setCellHeaderProps modifies the "th", but not the child "span" which has "flex"

Open
#1,258 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

## Expected Behavior
setCellHeaderProps should allow centering of the header cell text without breaking the border styling

## Current Behavior
setCellHeaderProps allows centering with flex, but misaligns the bottom border

## Steps to Reproduce (for bugs)

The highlighted line enables centered text, but causes a misaligned border (border line shifts up a few pixels)

![image](https://user-images.githubusercontent.com/1320083/79430419-c15da200-7f7d-11ea-8ea1-10be946ec3f7.png)

Border misaligned:

![image](https://user-images.githubusercontent.com/1320083/79430532-e94d0580-7f7d-11ea-9bbb-035bd622c9e7.png)

However, if you manually set "justify-content: center" on the child "span" tag using dev tools, you get the correct centering without any misaligned border:

![image](https://user-images.githubusercontent.com/1320083/79430711-36c97280-7f7e-11ea-8b6c-a6df97ff95af.png)

Centered without bottom border misalignment:

![image](https://user-images.githubusercontent.com/1320083/79430859-6b3d2e80-7f7e-11ea-98ac-45fb7bc82a9a.png)

## TL;DR ... final questions...

1. Is there a way to set the style props on the child `span` within the `th`?
1. Is there some other way to center the text of a header cell without misaligning the bottom border?

## Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 4.9.10 |
| MUI-datatables | 2.14.0 |
| React | 16.13.1 |
| browser | Chrome |

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how setCellHeaderProps is applied when rendering header cells, then inspect the generated th and child span styles in the table header. Reproduce the centered-header case in Chrome and verify that centering the text no longer shifts the bottom border; add or update a regression test if the repository has coverage for header styling.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.