Fix space panel edge gradient not applying on load (#7644)

This commit is contained in:
Michael Telatynski 2022-01-27 09:36:58 +00:00 committed by GitHub
parent 3eca71bc84
commit 3ff4c6808f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 30 deletions

View file

@ -18,6 +18,7 @@ import React, { ComponentProps, createRef } from "react";
import AutoHideScrollbar from "./AutoHideScrollbar";
import { replaceableComponent } from "../../utils/replaceableComponent";
import UIStore, { UI_EVENTS } from "../../stores/UIStore";
interface IProps extends Omit<ComponentProps<typeof AutoHideScrollbar>, "onWheel"> {
// If true, the scrollbar will append mx_IndicatorScrollbar_leftOverflowIndicator
@ -35,8 +36,8 @@ interface IProps extends Omit<ComponentProps<typeof AutoHideScrollbar>, "onWheel
}
interface IState {
leftIndicatorOffset: number | string;
rightIndicatorOffset: number | string;
leftIndicatorOffset: string;
rightIndicatorOffset: string;
}
@replaceableComponent("structures.IndicatorScrollbar")
@ -50,8 +51,8 @@ export default class IndicatorScrollbar extends React.Component<IProps, IState>
super(props);
this.state = {
leftIndicatorOffset: 0,
rightIndicatorOffset: 0,
leftIndicatorOffset: '0',
rightIndicatorOffset: '0',
};
}
@ -79,6 +80,7 @@ export default class IndicatorScrollbar extends React.Component<IProps, IState>
public componentDidMount(): void {
this.checkOverflow();
UIStore.instance.on(UI_EVENTS.Resize, this.checkOverflow);
}
private checkOverflow = (): void => {
@ -122,9 +124,8 @@ export default class IndicatorScrollbar extends React.Component<IProps, IState>
};
public componentWillUnmount(): void {
if (this.scrollElement) {
this.scrollElement.removeEventListener("scroll", this.checkOverflow);
}
this.scrollElement?.removeEventListener("scroll", this.checkOverflow);
UIStore.instance.off(UI_EVENTS.Resize, this.checkOverflow);
}
private onMouseWheel = (e: React.WheelEvent): void => {