Skip to content

Commit

Permalink
Only focus if scrolling is not disabled, fix precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeShi42 committed Jun 25, 2022
1 parent 520c1fc commit 932c9a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

./node_modules/.bin/repo-tools check-remote && lint-staged && flow
./node_modules/.bin/repo-tools check-remote && ./node_modules/.bin/lint-staged && ./node_modules/.bin/flow
7 changes: 5 additions & 2 deletions src/components/Step.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default class JoyrideStep extends React.Component {
status,
step,
update,
shouldScroll,
} = this.props;
const { changed, changedFrom } = treeChanges(prevProps, this.props);
const state = { action, controlled, index, lifecycle, size, status };
Expand Down Expand Up @@ -202,8 +203,10 @@ export default class JoyrideStep extends React.Component {
type: EVENTS.TOOLTIP,
});

this.scope = new Scope(this.tooltip, { selector: '[data-action=primary]' });
this.scope.setFocus();
this.scope = new Scope(this.tooltip, {
selector: '[data-action=primary]',
initialSetFocus: shouldScroll,
});
}

if (changedFrom('lifecycle', [LIFECYCLE.TOOLTIP, LIFECYCLE.INIT], LIFECYCLE.INIT)) {
Expand Down
4 changes: 3 additions & 1 deletion src/modules/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default class Scope {

window.addEventListener('keydown', this.handleKeyDown, false);

this.setFocus();
if (this.options.initialSetFocus !== false) {
this.setFocus();
}
}

canBeTabbed = (element: HTMLElement): boolean => {
Expand Down

0 comments on commit 932c9a8

Please sign in to comment.