Skip to content

Commit 5dbdfc0

Browse files
committed
Add forwardRef to CompanionWindow
1 parent 5daa657 commit 5dbdfc0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/components/CompanionWindow.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Children, cloneElement } from 'react';
1+
/* eslint-disable react/require-default-props */
2+
import { Children, cloneElement, forwardRef } from 'react';
23
import PropTypes from 'prop-types';
34
import { styled } from '@mui/material/styles';
45
import CloseIcon from '@mui/icons-material/CloseSharp';
@@ -26,11 +27,11 @@ const StyledCloseButton = styled(MiradorMenuButton, { name: 'CompanionWindow', s
2627
/**
2728
* CompanionWindow
2829
*/
29-
export function CompanionWindow(props) { // eslint-disable-line react/require-default-props
30+
export const CompanionWindow = forwardRef((props, innerRef) => {
3031
const {
3132
ariaLabel = undefined, classes = {}, direction, paperClassName = '', onCloseClick = () => {}, updateCompanionWindow = undefined, isDisplayed = false,
3233
position = null, title = null, children = undefined, titleControls = null,
33-
defaultSidebarPanelWidth = 235, defaultSidebarPanelHeight = 201, innerRef = undefined,
34+
defaultSidebarPanelWidth = 235, defaultSidebarPanelHeight = 201,
3435
} = props;
3536
const [sizeRef, size] = useElementSize();
3637
const { t } = useTranslation();
@@ -183,7 +184,7 @@ export function CompanionWindow(props) { // eslint-disable-line react/require-de
183184
</StyledRnd>
184185
</Root>
185186
);
186-
}
187+
});
187188

188189
CompanionWindow.propTypes = {
189190
ariaLabel: PropTypes.string,
@@ -192,10 +193,6 @@ CompanionWindow.propTypes = {
192193
defaultSidebarPanelHeight: PropTypes.number,
193194
defaultSidebarPanelWidth: PropTypes.number,
194195
direction: PropTypes.string.isRequired,
195-
innerRef: PropTypes.oneOfType([
196-
PropTypes.func,
197-
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
198-
]),
199196
isDisplayed: PropTypes.bool,
200197
onCloseClick: PropTypes.func,
201198
paperClassName: PropTypes.string,
@@ -208,3 +205,5 @@ CompanionWindow.propTypes = {
208205
titleControls: PropTypes.node,
209206
updateCompanionWindow: PropTypes.func,
210207
};
208+
209+
CompanionWindow.displayName = 'CompanionWindow';

0 commit comments

Comments
 (0)