Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbarbara committed Oct 28, 2023
1 parent 159110a commit 91e6e26
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,9 @@ class Joyride extends React.Component<Props, State> {
const { index, lifecycle } = this.state;
const { steps } = this.props;
const step = steps[index];
const intKey = window.Event ? event.which : event.keyCode;

if (lifecycle === LIFECYCLE.TOOLTIP) {
if (intKey === 27 && step && !step.disableCloseOnEsc) {
if (event.code === 'Escape' && step && !step.disableCloseOnEsc) {
this.store.close();
}
}
Expand Down Expand Up @@ -272,7 +271,7 @@ class Joyride extends React.Component<Props, State> {
} = this.props;
const step = getMergedStep(steps[index], this.props);

const target = getElement(step.target) as HTMLElement;
const target = getElement(step.target);
const shouldScrollToStep = shouldScroll({
isFirstStep: index === 0,
lifecycle,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function getElementPosition(
/**
* Get the scrollTop position
*/
export function getScrollTo(element: HTMLElement, offset: number, skipFix: boolean): number {
export function getScrollTo(element: HTMLElement | null, offset: number, skipFix: boolean): number {
if (!element) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface ShouldScrollOptions {
previousLifecycle: Lifecycle;
scrollToFirstStep: boolean;
step: Step;
target: HTMLElement;
target: HTMLElement | null;
}

export const isReact16 = createPortal !== undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ export default class Scope {
return;
}

const target = this.element.querySelector(selector) as HTMLElement;
const target = this.element.querySelector(selector);

/* istanbul ignore else */
if (target) {
window.requestAnimationFrame(() => this.checkFocus(target));
window.requestAnimationFrame(() => this.checkFocus(target as HTMLElement));
}
};
}
1 change: 0 additions & 1 deletion test/modules/scope.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ describe('modules/scope', () => {
});

it('should not have created an instance', () => {
// expect(Scope).toHaveBeenCalledTimes(1);
expect(scope).toBeUndefined();
});
});
Expand Down

0 comments on commit 91e6e26

Please sign in to comment.