Skip to content

Commit e2deac3

Browse files
committed
chore(v8): handle issues with React 18 in v8
1 parent 823b22c commit e2deac3

File tree

81 files changed

+677
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+677
-612
lines changed

packages/react/etc/react.api.md

Lines changed: 98 additions & 76 deletions
Large diffs are not rendered by default.

packages/react/src/components/Autofill/Autofill.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class Autofill extends React.Component<IAutofillProps, IAutofillState> im
3434
};
3535
// need to check WindowContext to get the provided document
3636
public static contextType = WindowContext;
37+
public context: React.ContextType<typeof WindowContext>;
3738

3839
private _inputElement = React.createRef<HTMLInputElement>();
3940
private _autoFillEnabled = true;
@@ -106,7 +107,7 @@ export class Autofill extends React.Component<IAutofillProps, IAutofillState> im
106107
return;
107108
}
108109

109-
const document = this.context?.window.document || getDocument(this._inputElement.current);
110+
const document = this.context?.window?.document || getDocument(this._inputElement.current);
110111
const isFocused = this._inputElement.current && this._inputElement.current === document?.activeElement;
111112

112113
if (

packages/react/src/components/Callout/CalloutContent.base.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ function useDismissHandlers(
469469
return mouseDownHandlers;
470470
}
471471

472-
export const CalloutContentBase: React.FunctionComponent<ICalloutProps> = React.memo(
472+
export const CalloutContentBase: React.FunctionComponent<React.PropsWithChildren<ICalloutProps>> = React.memo(
473473
React.forwardRef<HTMLDivElement, ICalloutProps>((propsWithoutDefaults, forwardedRef) => {
474474
const props = getPropsWithDefaults(DEFAULT_PROPS, propsWithoutDefaults);
475475

@@ -502,7 +502,7 @@ export const CalloutContentBase: React.FunctionComponent<ICalloutProps> = React.
502502

503503
const hostElement = React.useRef<HTMLDivElement>(null);
504504
const popupRef = React.useRef<HTMLDivElement>(null);
505-
const mergedPopupRefs = useMergedRefs(popupRef, popupProps?.ref);
505+
const mergedPopupRefs = useMergedRefs(popupRef, popupProps?.ref as React.Ref<HTMLDivElement>);
506506
const [calloutElement, setCalloutElement] = React.useState<HTMLDivElement | null>(null);
507507
const calloutCallback = React.useCallback((calloutEl: any) => {
508508
setCalloutElement(calloutEl);
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import * as React from 'react';
2+
import type { ICalloutProps } from './Callout.types';
23
import { styled } from '../../Utilities';
34
import { CalloutContentBase } from './CalloutContent.base';
45
import { getStyles } from './CalloutContent.styles';
5-
import type { ICalloutProps } from './Callout.types';
66

7-
export const CalloutContent: React.FunctionComponent<ICalloutProps> = styled(CalloutContentBase, getStyles, undefined, {
8-
scope: 'CalloutContent',
9-
});
7+
export const CalloutContent: React.FunctionComponent<React.PropsWithChildren<ICalloutProps>> = styled(
8+
CalloutContentBase,
9+
getStyles,
10+
undefined,
11+
{
12+
scope: 'CalloutContent',
13+
},
14+
);

packages/react/src/components/Callout/FocusTrapCallout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { IFocusTrapCalloutProps } from './FocusTrapCallout.types';
88
* A special Callout that uses FocusTrapZone to trap focus
99
* @param props - Props for the component
1010
*/
11-
export const FocusTrapCallout: React.FunctionComponent<IFocusTrapCalloutProps> = (
11+
export const FocusTrapCallout: React.FunctionComponent<React.PropsWithChildren<IFocusTrapCalloutProps>> = (
1212
props: IFocusTrapCalloutProps,
1313
): JSX.Element => {
1414
return (

packages/react/src/components/ColorPicker/ColorPicker.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ describe('ColorPicker', () => {
380380

381381
const redInput = getAllByRole('textbox')[1] as HTMLInputElement;
382382
userEvent.clear(redInput);
383-
userEvent.paste(redInput, '255');
383+
userEvent.paste('255');
384384
expect(onChange1).toHaveBeenCalledTimes(1);
385385
expect(newColor!.r).toBe(255);
386386
expect(colorPicker!.color.r).toBe(0);
@@ -550,12 +550,12 @@ describe('ColorPicker', () => {
550550

551551
// new value too long "pasted" => use substring
552552
userEvent.clear(redInput);
553-
userEvent.paste(redInput, '1000');
553+
userEvent.paste('1000');
554554
validateChange({ calls: 4, prop: 'r', value: 100, input: redInput });
555555

556556
// invalid new value too long "pasted" => use substring but don't call onChange
557557
userEvent.clear(redInput);
558-
userEvent.paste(redInput, '4567');
558+
userEvent.paste('4567');
559559

560560
validateChange({ calls: 4, prop: 'r', value: 100, input: redInput, inputValue: '456' });
561561
});
@@ -642,7 +642,7 @@ describe('ColorPicker', () => {
642642
validateChange({ calls: 1, prop: 'hex', value: '123456', input: hexInput });
643643

644644
// invalid new value too long "pasted" => ignore
645-
userEvent.paste(hexInput, 'hello world');
645+
userEvent.paste('hello world');
646646
validateChange({ calls: 1, prop: 'hex', value: '123456', input: hexInput });
647647
});
648648

@@ -719,7 +719,7 @@ describe('ColorPicker', () => {
719719

720720
// value too large => allowed in field but onChange not called
721721
userEvent.clear(transparencyInput);
722-
userEvent.paste(transparencyInput, '123');
722+
userEvent.paste('123');
723723
expect(onChange).toHaveBeenCalledTimes(0);
724724
expect(colorPicker!.color.a).toBe(30); // original value
725725
expect(colorPicker!.color.t).toBe(70);

packages/react/src/components/ColorPicker/ColorPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ColorPickerBase } from './ColorPicker.base';
44
import { getStyles } from './ColorPicker.styles';
55
import type { IColorPickerProps, IColorPickerStyles, IColorPickerStyleProps } from './ColorPicker.types';
66

7-
export const ColorPicker: React.FunctionComponent<IColorPickerProps> = styled<
7+
export const ColorPicker: React.FunctionComponent<React.PropsWithChildren<IColorPickerProps>> = styled<
88
IColorPickerProps,
99
IColorPickerStyleProps,
1010
IColorPickerStyles

packages/react/src/components/ColorPicker/ColorRectangle/ColorRectangle.base.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ export class ColorRectangleBase
2929
implements IColorRectangle
3030
{
3131
public static contextType = WindowContext;
32+
3233
public static defaultProps: Partial<IColorRectangleProps> = {
3334
minSize: 220,
3435
ariaLabel: 'Saturation and brightness',
3536
ariaValueFormat: 'Saturation {0} brightness {1}',
3637
ariaDescription: 'Use left and right arrow keys to set saturation. Use up and down arrow keys to set brightness.',
3738
};
3839

40+
public context: React.ContextType<typeof WindowContext>;
41+
3942
private _disposables: (() => void)[] = [];
4043
private _root = React.createRef<HTMLDivElement>();
4144
private _isAdjustingSaturation: boolean = true;

packages/react/src/components/ColorPicker/ColorRectangle/ColorRectangle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ColorRectangleBase } from './ColorRectangle.base';
44
import { getStyles } from './ColorRectangle.styles';
55
import type { IColorRectangleProps, IColorRectangleStyles, IColorRectangleStyleProps } from './ColorRectangle.types';
66

7-
export const ColorRectangle: React.FunctionComponent<IColorRectangleProps> = styled<
7+
export const ColorRectangle: React.FunctionComponent<React.PropsWithChildren<IColorRectangleProps>> = styled<
88
IColorRectangleProps,
99
IColorRectangleStyleProps,
1010
IColorRectangleStyles

packages/react/src/components/ColorPicker/ColorSlider/ColorSlider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ColorSliderBase } from './ColorSlider.base';
44
import { getStyles } from './ColorSlider.styles';
55
import type { IColorSliderProps, IColorSliderStyleProps, IColorSliderStyles } from './ColorSlider.types';
66

7-
export const ColorSlider: React.FunctionComponent<IColorSliderProps> = styled<
7+
export const ColorSlider: React.FunctionComponent<React.PropsWithChildren<IColorSliderProps>> = styled<
88
IColorSliderProps,
99
IColorSliderStyleProps,
1010
IColorSliderStyles

0 commit comments

Comments
 (0)