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

chore: upgrade react-transition-group #4537

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions fork/react-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
"keycode": "^2.2.1",
"prop-types": "^15.8.1",
"prop-types-extra": "^1.1.1",
"react-overlays": "^0.9.3",
"react-overlays": "^5.2.1",
"react-prop-types": "^0.4.0",
"react-transition-group": "^2.9.0",
"react-transition-group": "^4.4.5",
"uncontrollable": "^7.2.1",
"warning": "^3.0.0"
},
Expand Down
28 changes: 21 additions & 7 deletions fork/react-bootstrap/src/DropdownMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ import keycode from 'keycode';
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import RootCloseWrapper from 'react-overlays/lib/RootCloseWrapper';
import useRootClose from 'react-overlays/cjs/useRootClose';

function RootCloseWrapper(props) {
/** ref: React.RefObject<Element> | Element | null | undefined,
onRootClose: (e: Event) => void,
{ disabled, clickTrigger = 'click' }: RootCloseOptions = {}, */
useRootClose(props.myRef, props.onRootClose, {
disabled: props.disabled,
clickTrigger: props.clickTrigger,
});
return props.children;
}

import {
bsClass,
getClassSet,
prefix,
splitBsPropsAndOmit
splitBsPropsAndOmit,
} from './utils/bootstrapUtils';
import createChainedFunction from './utils/createChainedFunction';
import ValidComponentChildren from './utils/ValidComponentChildren';
Expand All @@ -20,12 +31,12 @@ const propTypes = {
onClose: PropTypes.func,
labelledBy: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onSelect: PropTypes.func,
rootCloseEvent: PropTypes.oneOf(['click', 'mousedown'])
rootCloseEvent: PropTypes.oneOf(['click', 'mousedown']),
};

const defaultProps = {
bsRole: 'menu',
pullRight: false
pullRight: false,
};

class DropdownMenu extends React.Component {
Expand All @@ -34,6 +45,7 @@ class DropdownMenu extends React.Component {

this.handleRootClose = this.handleRootClose.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this);
this.myRef = React.createRef();
}

getFocusableMenuItems() {
Expand Down Expand Up @@ -110,28 +122,30 @@ class DropdownMenu extends React.Component {

const classes = {
...getClassSet(bsProps),
[prefix(bsProps, 'right')]: pullRight
[prefix(bsProps, 'right')]: pullRight,
};

return (
<RootCloseWrapper
disabled={!open}
onRootClose={this.handleRootClose}
event={rootCloseEvent}
myRef={this.myRef}
>
<ul
{...elementProps}
role="menu"
ref={this.myRef}
className={classNames(className, classes)}
aria-labelledby={labelledBy}
>
{ValidComponentChildren.map(children, child =>
{ValidComponentChildren.map(children, (child) =>
React.cloneElement(child, {
onKeyDown: createChainedFunction(
child.props.onKeyDown,
this.handleKeyDown
),
onSelect: createChainedFunction(child.props.onSelect, onSelect)
onSelect: createChainedFunction(child.props.onSelect, onSelect),
})
)}
</ul>
Expand Down
24 changes: 12 additions & 12 deletions fork/react-bootstrap/src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import getScrollbarSize from 'dom-helpers/util/scrollbarSize';
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import BaseModal from 'react-overlays/lib/Modal';
import isOverflowing from 'react-overlays/lib/utils/isOverflowing';
import BaseModal from 'react-overlays/cjs/Modal';
import isOverflowing from 'react-overlays/cjs/isOverflowing';
import elementType from 'prop-types-extra/lib/elementType';

import Fade from './Fade';
Expand Down Expand Up @@ -119,19 +119,19 @@ const propTypes = {
/**
* @private
*/
container: BaseModal.propTypes.container
container: BaseModal.propTypes.container,
};

const defaultProps = {
...BaseModal.defaultProps,
animation: true,
dialogComponentClass: ModalDialog
dialogComponentClass: ModalDialog,
};

const childContextTypes = {
$bs_modal: PropTypes.shape({
onHide: PropTypes.func
})
onHide: PropTypes.func,
}),
};

/* eslint-disable no-use-before-define, react/no-multi-comp */
Expand All @@ -156,15 +156,15 @@ class Modal extends React.Component {
this.setModalRef = this.setModalRef.bind(this);

this.state = {
style: {}
style: {},
};
}

getChildContext() {
return {
$bs_modal: {
onHide: this.props.onHide
}
onHide: this.props.onHide,
},
};
}

Expand Down Expand Up @@ -225,16 +225,16 @@ class Modal extends React.Component {
paddingLeft:
!bodyIsOverflowing && modalIsOverflowing
? getScrollbarSize()
: undefined
}
: undefined,
},
});
}

handleDialogBackdropMouseDown = () => {
this._waitingForMouseUp = true;
};

handleMouseUp = ev => {
handleMouseUp = (ev) => {
const dialogNode = this._modal.getDialogElement();
if (this._waitingForMouseUp && ev.target === dialogNode) {
this._ignoreBackdropClick = true;
Expand Down
2 changes: 1 addition & 1 deletion fork/react-bootstrap/src/Modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import events from 'dom-helpers/events';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-dom/test-utils';
import BaseModal from 'react-overlays/lib/Modal';
import BaseModal from 'react-overlays/cjs/Modal';

import Modal from '../src/Modal';

Expand Down
8 changes: 4 additions & 4 deletions fork/react-bootstrap/src/Overlay.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import React, { cloneElement } from 'react';
import PropTypes from 'prop-types';
import BaseOverlay from 'react-overlays/lib/Overlay';
import BaseOverlay from 'react-overlays/cjs/Overlay';
import elementType from 'prop-types-extra/lib/elementType';

import Fade from './Fade';
Expand Down Expand Up @@ -61,14 +61,14 @@ const propTypes = {
/**
* Sets the direction of the Overlay.
*/
placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left'])
placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
};

const defaultProps = {
animation: Fade,
rootClose: false,
show: false,
placement: 'right'
placement: 'right',
};

class Overlay extends React.Component {
Expand All @@ -81,7 +81,7 @@ class Overlay extends React.Component {

if (!transition) {
child = cloneElement(children, {
className: classNames(children.props.className, 'in')
className: classNames(children.props.className, 'in'),
});
} else {
child = children;
Expand Down
10 changes: 5 additions & 5 deletions fork/react-bootstrap/test/ModalSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import events from 'dom-helpers/events';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-dom/test-utils';
import BaseModal from 'react-overlays/lib/Modal';
import BaseModal from 'react-overlays/cjs/Modal';

import Modal from '../src/Modal';

Expand Down Expand Up @@ -33,7 +33,7 @@ describe('<Modal>', () => {
assert.ok(instance._modal.getDialogElement().querySelector('strong'));
});

it('Should close the modal when the modal dialog is clicked', done => {
it('Should close the modal when the modal dialog is clicked', (done) => {
const doneOp = () => {
done();
};
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('<Modal>', () => {
expect(onHideSpy).to.not.have.been.called;
});

it('Should close the modal when the modal close button is clicked', done => {
it('Should close the modal when the modal close button is clicked', (done) => {
const doneOp = () => {
done();
};
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('<Modal>', () => {
assert.equal(instance._modal.getDialogElement().className, 'custom-dialog');
});

it('Should pass transition callbacks to Transition', done => {
it('Should pass transition callbacks to Transition', (done) => {
let count = 0;
const increment = () => {
++count;
Expand Down Expand Up @@ -252,7 +252,7 @@ describe('<Modal>', () => {
super(props, context);

this.state = {
show: true
show: true,
};
}

Expand Down
3 changes: 2 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"classnames": "^2.3.2",
"d3": "^7.8.5",
"date-fns": "^1.30.1",
"dom-helpers": "^5.0.1",
"focus-outline-manager": "^1.0.2",
"immutable": "^3.8.2",
"invariant": "^2.2.4",
Expand All @@ -58,7 +59,7 @@
"react-immutable-proptypes": "^2.2.0",
"react-is": "^17.0.0",
"react-popper": "^2.3.0",
"react-transition-group": "^2.9.0",
"react-transition-group": "^4.4.5",
"react-use": "^17.4.0",
"react-virtualized": "^9.22.5",
"reactour": "^1.19.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"modern-css-reset": "^1.4.0",
"polished": "^4.2.2",
"react-use": "^17.4.0",
"react-transition-group": "^2.2.9",
"react-transition-group": "^4.4.5",
"typeface-inconsolata": "^1.1.13",
"typeface-source-sans-pro": "^1.1.13"
},
Expand Down Expand Up @@ -74,7 +74,7 @@
"@types/react-is": "^18.2.0",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@types/react-transition-group": "^2.9.2",
"@types/react-transition-group": "^4.4.8",
"browser-sync": "^2.29.3",
"browser-sync-webpack-plugin": "^2.3.0",
"concurrently": "^7.6.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/stepper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"react-dom": "^18.2.0",
"react-i18next": "^13.3.0",
"react-redux": "^7.2.9",
"react-transition-group": "^2.9.0"
"react-transition-group": "^4.4.5"
},
"peerDependencies": {
"i18next": "^23.5.1",
Expand All @@ -64,7 +64,7 @@
"react-dom": ">= 16.14.0",
"react-hook-form": ">=6.15.8",
"react-i18next": "^13.3.0",
"react-transition-group": "^2.3.1"
"react-transition-group": "^4.4.5"
},
"publishConfig": {
"access": "public"
Expand Down