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: remove support for component labels in Pagination #775

Merged
merged 1 commit into from Jul 2, 2021

Conversation

davidjoy
Copy link
Contributor

@davidjoy davidjoy commented Jul 2, 2021

BREAKING CHANGE:

This commit removes support for passing React components as buttonLabels or paginationLabel in the Pagination component. The values of both attributes must now be strings. If you were using FormattedMessage to pass a label into Pagination, then you must use intl.formatMessage instead so that the return value is a string.

This removes our dependency on sanitize-html, which is a package we were using to turn component-based labels back into plain strings. sanitize-html v2.x is compatible with PostCSS 8, a requirement for our upgrade to webpack 5. Unfortunately v2.x also drops ES5 support, which we also need. So the dependency needed to go.

To upgrade your components, pass plain string labels into buttonLabels or paginationLabel instead of components or JSX. There are no known places where people are doing this, so it should be a no-op for known MFEs.

BREAKING CHANGE:

This commit removes support for passing React components as `buttonLabels` in the Pagination component.  `buttonLabels` must now be strings.  If you were using `FormattedMessage` to pass a label into Pagination, then you must use `intl.formatMessage` instead so that the return value is a string.

This removes our dependency on `sanitize-html`, which is a package we were using to turn component-based labels back into plain strings.  `sanitize-html` v2.x is compatible with PostCSS 8, a requirement for our upgrade to webpack 5.  Unfortunately v2.x also drops ES5 support, which we also need.  So the dependency needed to go.

To upgrade your components, pass plain string labels to `buttonLabels` instead of components or JSX.  There are no known places where people are doing this, so it should be a no-op for known MFEs.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 90.616% when pulling c858f06 on djoy/remove_sanitize-html_from_pagination into a8af4c3 on master.

@@ -21,6 +21,24 @@ describe('<Pagination />', () => {
expect(wrapper.exists()).toEqual(true);
});

it('renders screen reader section', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't tested, so I added this so I could validate my change.

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.

Looks great! :shipit:

@@ -371,7 +326,7 @@ Pagination.propTypes = {
/** specifies the total number of pages in the `Pagination` component. */
pageCount: PropTypes.number.isRequired,
/** specifies the `aria-label` for the `<nav>` element that wraps the pagination button list. */
paginationLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
paginationLabel: PropTypes.string.isRequired,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noted that this label also specified it could be an element, but that it stuffs the value directly into an aria-label attribute. There's no way that could be anything other than a string, so I removed the erroneous prop type.

@@ -3487,6 +3487,7 @@
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these "dev": true are telling - sanitize-html had dependencies that were generally only dev dependencies... but we were adding them into our app. Ouch.

@@ -13916,16 +13855,6 @@
"integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=",
"dev": true
},
"postcss": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line is the payoff of this entire thing - we need this dependency to go away! It's preventing us from upgrading to webpack 5, since the latest and greatest packages in the ecosystem all require PostCSS 8, and it gets installed as a peer dependency. Dependencies like this line were superceding our attempts at installing PostCSS 8 and breaking everything.

@@ -49,7 +49,6 @@
"react-responsive": "^6.1.1",
"react-table": "^7.6.1",
"react-transition-group": "^4.0.0",
"sanitize-html": "^1.27.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Goodnight, sweet prince.

@davidjoy davidjoy merged commit 2ffba6e into master Jul 2, 2021
@davidjoy davidjoy deleted the djoy/remove_sanitize-html_from_pagination branch July 2, 2021 18:54
@edx-semantic-release
Copy link
Contributor

🎉 This PR is included in version 16.0.0 🎉

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

4 participants