Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Use the resize observer polyfill consistently #7796

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/views/elements/PersistedElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { ActionPayload } from "../../../dispatcher/payloads";
import { ResizeObserverPolyfill } from "../../../stores/UIStore";

export const getPersistKey = (appId: string) => 'widget_' + appId;

Expand Down Expand Up @@ -80,7 +81,7 @@ export default class PersistedElement extends React.Component<IProps> {
constructor(props: IProps) {
super(props);

this.resizeObserver = new ResizeObserver(this.repositionChild);
this.resizeObserver = new ResizeObserverPolyfill(this.repositionChild);
// Annoyingly, a resize observer is insufficient, since we also care
// about when the element moves on the screen without changing its
// dimensions. Doesn't look like there's a ResizeObserver equivalent
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/messages/CallEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import InfoTooltip, { InfoTooltipKind } from '../elements/InfoTooltip';
import AccessibleTooltipButton from '../elements/AccessibleTooltipButton';
import { formatCallTime } from "../../../DateUtils";
import Clock from "../audio_messages/Clock";
import { ResizeObserverPolyfill } from "../../../stores/UIStore";

const MAX_NON_NARROW_WIDTH = 450 / 70 * 100;

Expand Down Expand Up @@ -63,7 +64,7 @@ export default class CallEvent extends React.PureComponent<IProps, IState> {
this.props.callEventGrouper.addListener(CallEventGrouperEvent.SilencedChanged, this.onSilencedChanged);
this.props.callEventGrouper.addListener(CallEventGrouperEvent.LengthChanged, this.onLengthChanged);

this.resizeObserver = new ResizeObserver(this.resizeObserverCallback);
this.resizeObserver = new ResizeObserverPolyfill(this.resizeObserverCallback);
this.wrapperElement.current && this.resizeObserver.observe(this.wrapperElement.current);
}

Expand Down
4 changes: 2 additions & 2 deletions src/stores/UIStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import ResizeObserverEntry from 'resize-observer-polyfill/src/ResizeObserverEntr

// XXX: resize-observer-polyfill has types that now conflict with typescript's
// own DOM types: https://github.com/que-etc/resize-observer-polyfill/issues/80
// Using require here rather than import is a horrenous workaround. We should
// Using require here rather than import is a horrendous workaround. We should
// be able to remove the polyfill once Safari 14 is released.
const ResizeObserverPolyfill = require('resize-observer-polyfill'); // eslint-disable-line @typescript-eslint/no-var-requires
export const ResizeObserverPolyfill = require('resize-observer-polyfill'); // eslint-disable-line @typescript-eslint/no-var-requires

export enum UI_EVENTS {
Resize = "resize"
Expand Down