Skip to content

Commit

Permalink
fix: re-publish broken release
Browse files Browse the repository at this point in the history
  • Loading branch information
Matej Snuderl committed Feb 19, 2020
1 parent 55a86ec commit da454bf
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,26 @@ class MicroModal extends React.PureComponent<Props, State> {
});
};

private handleOpen = (): void => {
private handleOpen = () => {
this.setState({ open: true }, this.onAfterOpen);
};

private onAfterOpen = (): void => {
private onAfterOpen = () => {
this.lastElement = document.activeElement as HTMLElement;
openContainerRefStack.push(this.containerRef);
this.addEventListeners();
this.focusFirstNode();
};

private addEventListeners = (): void => {
private addEventListeners = () => {
document.addEventListener('keydown', this.onKeydown);
if (this.props.closeOnOverlayClick) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.modalRef.current!.addEventListener('click', this.onClick);
}
};

private startClosingUncontrolled = (): void => {
private startClosingUncontrolled = () => {
this.setState({ isClosing: true }, () => {
this.closeOnAnimationEnd(this._handleCloseAnimationEnd);
});
Expand All @@ -146,11 +146,11 @@ class MicroModal extends React.PureComponent<Props, State> {
}
};

private _handleCloseAnimationEnd = (): void => {
private _handleCloseAnimationEnd = () => {
this.setState({ open: false, isClosing: false }, this.onAfterClose);
};

private onAfterClose = (): void => {
private onAfterClose = () => {
this.removeEventListeners();
openContainerRefStack.pop();
if (this.lastElement) {
Expand All @@ -159,23 +159,23 @@ class MicroModal extends React.PureComponent<Props, State> {
}
};

private focusFirstNode(): void {
private focusFirstNode() {
if (this.props.disableFirstElementFocus) {
return;
}

focusFirstNode(this.containerRef);
}

private removeEventListeners = (): void => {
private removeEventListeners = () => {
document.removeEventListener('keydown', this.onKeydown);
if (this.props.closeOnOverlayClick) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.modalRef.current!.removeEventListener('click', this.onClick);
}
};

private onClick = (event: MouseEvent): void => {
private onClick = (event: MouseEvent) => {
if (
event.target &&
this.containerRef.current &&
Expand All @@ -186,7 +186,7 @@ class MicroModal extends React.PureComponent<Props, State> {
}
};

private onKeydown = (event: KeyboardEvent): void => {
private onKeydown = (event: KeyboardEvent) => {
if (this.containerRef === getLastOpenContainer()) {
if (event.key === ESCAPE_KEY && this.props.closeOnEscapePress) {
event.stopPropagation();
Expand Down

0 comments on commit da454bf

Please sign in to comment.