Skip to content
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

fix: removes TableCell wrapper #810

Merged
merged 1 commit into from
Sep 9, 2021
Merged

fix: removes TableCell wrapper #810

merged 1 commit into from
Sep 9, 2021

Conversation

ciduarte
Copy link

@ciduarte ciduarte commented Sep 7, 2021

  • removes TableCell wrapper from <td>

@coveralls
Copy link

coveralls commented Sep 7, 2021

Coverage Status

Coverage increased (+0.004%) to 87.333% when pulling ac9c0b9 on ciduarte/aa-934 into d8dec97 on master.

Comment on lines 27 to 28
/** Class names for the td element */
className: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not fully aware of the problem here, but it might be good to name this like dataClassName or tdClassName or something?

Or pulling back, this distinction seems so minute - block level vs inline? Is that a real distinction we want to expose? Could we move the cellClassName up to the td level safely, to solve the same problem you are looking at? Or is that an API break?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure what the original justification was for adding the cellClassName to the inline element vs the block element here, but I agree this feels a little redundant. Though, .pgn__data-table-cell-wrap has some styling that we may want to override (ex. .pgn__data-table-cell-wrap has a max-width and I found an edX repo that overrides it to none).

My use case for exposing the td element's className was to change its vertical alignment, which you can't access through the inline element.

I think given that there are use cases for both, it makes sense to expose both but update the names?

Copy link
Contributor

Choose a reason for hiding this comment

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

You may need someone more in tune with paragon than me.

Is moving .pgn__data-table-cell-wrap up to <td> and dropping the <span> altogether a bad idea?

Copy link
Author

Choose a reason for hiding this comment

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

I just tried to drop the span and update the styling and it didn't really go well, so I think that might be a bad idea

@adamstankiewicz
Copy link
Member

adamstankiewicz commented Sep 8, 2021

I just tried to drop the span and update the styling and it didn't really go well, so I think that might be a bad idea

The code below seems to work locally without incorporating any breaking changes or the existing styles.

@ciduarte I think the styling issues you were running into might have been that .pgn__data-table-cell-wrap has display: block, so when it was placed on the td directly, the display: table-cell that should be on the td was overridden. Removing the display: block from the .pgn__data-table-cell-wrap styles seems to work well.

image

const TableCell = ({ getCellProps, render, column }) => (
  <td {...getCellProps({ className: classNames('pgn__data-table-cell-wrap', column.cellClassName) })}>
    {render('Cell')}
  </td>
);
.pgn__data-table-cell-wrap {
  max-width: 20vw;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

All the current uses of cellClassName should still work with this change, including the max-width: unset override. That override actually happens in two edX repos. One overrides the .pgn__data-table-cell-wrap class directly (anti-pattern), and the other passes a custom class name to cellClassName that handles the max-width: unset itself.

The other current uses of cellClassName will continue to work as is (e.g., float-right font-weight-bold small, mw-100).

@ciduarte
Copy link
Author

ciduarte commented Sep 8, 2021

@adamstankiewicz thanks for looking into this! I did try that yesterday, and didn't see any broken styling on the Paragon site. What I saw was specific to frontend-app-learning, and I couldn't get to the bottom of it so I assumed it would be an issue everywhere. Giving it a second look, I realized what was happening and this change feels safe to make!

For the curious, this change was impacting some cells that used float-right. Switching the cells to use text-right fixed the issue.
Screen Shot 2021-09-08 at 1 32 24 PM

@ciduarte ciduarte force-pushed the ciduarte/aa-934 branch 3 times, most recently from 579b5da to 0e7a228 Compare September 8, 2021 17:53
@ciduarte ciduarte changed the title feat: add className to DataTable td element fix: removes TableCell wrapper Sep 8, 2021
Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

:shipit:

@ciduarte ciduarte merged commit f9996ec into master Sep 9, 2021
@ciduarte ciduarte deleted the ciduarte/aa-934 branch September 9, 2021 14:05
@edx-semantic-release
Copy link
Contributor

🎉 This PR is included in version 16.13.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants