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

Update autofocus to use 'on' and 'off' #201

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/transcend-io/consent-manager-ui.git"
},
"homepage": "https://github.com/transcend-io/consent-manager-ui",
"version": "4.23.0",
"version": "4.24.0",
"license": "MIT",
"main": "build/ui",
"files": [
Expand Down Expand Up @@ -51,7 +51,7 @@
"@prettier/sync": "^0.5.2",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/preact": "^3.2.4",
"@transcend-io/airgap.js-types": "^12.6.0",
"@transcend-io/airgap.js-types": "^12.7.0",
"@transcend-io/type-utils": "^1.5.0",
"@types/jest": "^29.5.12",
"@types/node": "^17.0.45",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function Main({
const dialogRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!isViewStateClosed(viewState) && dialogRef.current) {
const shouldAutofocus = config.autofocus ?? true;
const shouldAutofocus = config?.autofocus !== 'off';
// This setTimeout was necessary for the api triggered states, (DoNotSell|OptOut)Disclosure
setTimeout(() => {
if (dialogRef.current && shouldAutofocus) {
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export function useViewState({
eventTarget: EventTarget;
/** Element previously focused before our ui modal was opened */
savedActiveElement: HTMLElement | null;
/** Whether to on last focused element on reopen */
autofocus?: boolean;
/** Whether to on last focused element on reopen: on or off */
autofocus?: string;
}): {
/** The current view state */
viewState: ViewState;
Expand Down Expand Up @@ -137,7 +137,7 @@ export function useViewState({
* very difficult to interact with. We create an element with maximum focus priority and
* focus it so that when we delete it the user will be at the start of the focus order
* just like if they had freshly loaded the page. */
const shouldFocus = autofocus ?? true;
const shouldFocus = autofocus !== 'off';
if (savedActiveElement !== null && shouldFocus) {
savedActiveElement.focus();
} else {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1123,14 +1123,14 @@ __metadata:
languageName: node
linkType: hard

"@transcend-io/airgap.js-types@npm:^12.6.0":
version: 12.6.0
resolution: "@transcend-io/airgap.js-types@npm:12.6.0"
"@transcend-io/airgap.js-types@npm:^12.7.0":
version: 12.7.0
resolution: "@transcend-io/airgap.js-types@npm:12.7.0"
dependencies:
"@transcend-io/type-utils": "npm:^1.2.0"
fp-ts: "npm:^2.16.1"
io-ts: "npm:^2.2.21"
checksum: 10/4d22a5b1b77c3b2d03995f142171d69664df31d6212bd2776762a5aa90cb6f2b0bfe44b8d00f3647be1558dab8080348d7cd6800aeee2d510de6b7aa2699a88a
checksum: 10/df8d244c633f0f205c0e2382aaea5da0d5d64fc45d6473bf33a7cccbfc880c0703324b7f37469692f7a4ad3b43d14187cfa9a814c51275d9729e527b815242d6
languageName: node
linkType: hard

Expand All @@ -1155,7 +1155,7 @@ __metadata:
"@prettier/sync": "npm:^0.5.2"
"@testing-library/jest-dom": "npm:^6.4.6"
"@testing-library/preact": "npm:^3.2.4"
"@transcend-io/airgap.js-types": "npm:^12.6.0"
"@transcend-io/airgap.js-types": "npm:^12.7.0"
"@transcend-io/internationalization": "npm:^1.6.0"
"@transcend-io/logger": "npm:^1.1.0"
"@transcend-io/type-utils": "npm:^1.5.0"
Expand Down
Loading