Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WRR-1063: Added a QA sampler for Spotlight.focus with preventScroll option #1697

Merged
merged 6 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist: jammy
language: node_js
node_js:
- lts/*
- 21
sudo: false
before_install:
- curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-4.4.gpg --dearmor
Expand Down
31 changes: 30 additions & 1 deletion samples/sampler/stories/qa/Spotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {boolean, select} from '@enact/storybook-utils/addons/controls';
import {Row, Cell, Column} from '@enact/ui/Layout';
import ri from '@enact/ui/resolution';
import PropTypes from 'prop-types';
import {Component, cloneElement} from 'react';
import {Component, cloneElement, useCallback} from 'react';

import css from './Spotlight.module.less';

Expand Down Expand Up @@ -518,6 +518,35 @@ export const FocusRing = () => (

FocusRing.storyName = 'Spottable with Focus Ring';

export const FocusWithPreventScroll = () => {
const handleClickNotPrevented = useCallback(() => {
Spotlight.focus('#FocusWithPreventScrollTarget1');
}, []);

const handleClickPrevented = useCallback(() => {
Spotlight.focus('#FocusWithPreventScrollTarget2', {preventScroll: true});
}, []);

return (
<>
<p>Press OK button on the first button calls Spotlight.focus() to focus the second button for each scroller.</p>
Without preventScroll option
<div className={css.scroller}>
<Button className={css.block} onClick={handleClickNotPrevented}>Press OK on this button</Button>
<Button className={css.block} id="FocusWithPreventScrollTarget1">To be scrolled</Button>
</div>
<br />
With preventScroll: true option
<div className={css.scroller}>
<Button className={css.block} onClick={handleClickPrevented}>Press OK on this button</Button>
<Button className={css.block} id="FocusWithPreventScrollTarget2">Not to be scrolled</Button>
</div>
</>
);
};

FocusWithPreventScroll.storyName = 'Focus with preventScroll';

export const KitchenSink = (args) => (
<Column>
<Cell component="p" shrink>
Expand Down
10 changes: 10 additions & 0 deletions samples/sampler/stories/qa/Spotlight.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@
transform: scale(1.1);
});
}

.scroller {
overflow-y: scroll;
height: 240px;
border: 6px solid orangered;
}

.block {
display: block;
}