Skip to content

Commit 220b988

Browse files
feat: add accessibility and focusOnChange settings to carousel (#4156)
## Description Adding these settings to help make the carousel component compliant with a11y requirements. Settings default to off so that existing workflows are not disrupted. **JIRA ticket** https://builder-io.atlassian.net/browse/ENG-10325 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds accessibility and focusOnSelect options to the Carousel and upgrades react-slick, with a minor version bump and related dependency updates. > > - **Widgets/Carousel**: > - Add `accessibility` and `focusOnSelect` inputs in `Carousel.config.ts` (advanced, default `false`). > - Pass `accessibility` and `focusOnSelect` props to `react-slick` in `Carousel.tsx`. > - **Dependencies**: > - Upgrade `react-slick` to `^0.31.0` and `@types/react-slick` to `^0.23.13`. > - Lockfile reflects updated peer ranges and removal of transitive `enquire.js`. > - **Release & Scripts**: > - Bump package version to `2.1.0` and add `release:minor` script. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 692c7a5. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Signed-off-by: Sanyam Kamat <[email protected]> Co-authored-by: Sanyam Kamat <[email protected]>
1 parent b49671e commit 220b988

File tree

4 files changed

+38
-30
lines changed

4 files changed

+38
-30
lines changed

packages/widgets/package-lock.json

Lines changed: 8 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/widgets/package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@builder.io/widgets",
3-
"version": "2.0.3",
3+
"version": "2.1.0",
44
"description": "",
55
"keywords": [],
66
"main": "dist/builder-widgets.cjs.js",
@@ -35,6 +35,7 @@
3535
"commit": "git-cz",
3636
"release": "npm run build && ALLOW_PUBLISH=true npm publish",
3737
"release:major": "npm run build && npm version major && ALLOW_PUBLISH=true npm publish",
38+
"release:minor": "npm run build && npm version minor && ALLOW_PUBLISH=true npm publish",
3839
"release:patch": "npm run build && npm version patch --no-git-tag-version && ALLOW_PUBLISH=true npm publish",
3940
"release:nightly": "npm run build && npm version prerelease --no-git-tag-version && ALLOW_PUBLISH=true npm publish --tag nightly",
4041
"release:dev": "npm run build && npm version prerelease --no-git-tag-version && ALLOW_PUBLISH=true npm publish --tag dev",
@@ -93,21 +94,23 @@
9394
"@types/react": "^16.4.1",
9495
"@types/react-dom": "^16.0.7",
9596
"@types/react-loadable": "^5.5.1",
96-
"@types/react-slick": "^0.23.4",
97+
"@types/react-slick": "^0.23.13",
9798
"colors": "^1.1.2",
9899
"commitizen": "^4.3.1",
100+
"concurrently": "^5.3.0",
99101
"coveralls": "^3.0.0",
100102
"cross-env": "^5.0.1",
101103
"cz-conventional-changelog": "^2.0.0",
102-
"concurrently": "^5.3.0",
103-
"rollup-plugin-serve": "^1.0.1",
104104
"husky": "^0.14.0",
105105
"jest": "^29.0.0",
106106
"lint-staged": "^15.3.0",
107107
"lodash.camelcase": "^4.3.0",
108+
"next": "^12.1.0",
108109
"npm-install-peers": "^1.2.1",
109110
"prettier": "^1.4.4",
110111
"prompt": "^1.0.0",
112+
"react": "^17.0.2",
113+
"react-dom": "^17.0.2",
111114
"replace-in-file": "^3.0.0-beta.2",
112115
"rimraf": "^2.6.1",
113116
"rollup": "^2.33.3",
@@ -117,6 +120,7 @@
117120
"rollup-plugin-node-resolve": "^5.2.0",
118121
"rollup-plugin-re": "^1.0.7",
119122
"rollup-plugin-replace": "^2.0.0",
123+
"rollup-plugin-serve": "^1.0.1",
120124
"rollup-plugin-sourcemaps": "^0.6.3",
121125
"rollup-plugin-typescript2": "^0.31.2",
122126
"semantic-release": "^19.0.3",
@@ -127,18 +131,15 @@
127131
"tslint-config-standard": "^7.0.0",
128132
"typedoc": "^0.26.10",
129133
"typescript": "^5.4.5",
130-
"validate-commit-msg": "^2.12.2",
131-
"next": "^12.1.0",
132-
"react": "^17.0.2",
133-
"react-dom": "^17.0.2"
134+
"validate-commit-msg": "^2.12.2"
134135
},
135136
"peerDependencies": {
137+
"@builder.io/react": ">=5.0.11",
138+
"next": ">=12.1.0",
136139
"preact": "^8.4.2",
137140
"preact-compat": "^3.18.4",
138141
"preact-context": "^1.1.3",
139142
"prop-types": "^15.7.2",
140-
"next": ">=12.1.0",
141-
"@builder.io/react": ">=5.0.11",
142143
"react": ">=16.0.0-0 || ^19.0.0-rc",
143144
"react-dom": ">=16.0.0-0 || ^19.0.0-rc"
144145
},
@@ -165,7 +166,7 @@
165166
"lodash-es": "^4.17.10",
166167
"react-loadable": "^5.5.0",
167168
"react-masonry-component": "^6.2.1",
168-
"react-slick": "^0.28.1",
169+
"react-slick": "^0.31.0",
169170
"tslib": "^1.10.0"
170171
},
171172
"gitHead": "4d96fbc32864698afbb355ab991c6d90be991951"

packages/widgets/src/components/Carousel.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,19 @@ export const carouselConfig: any = {
200200
},
201201
],
202202
},
203+
{
204+
name: 'accessibility',
205+
helperText: 'Enable accessibility features for screen readers and keyboard navigation',
206+
type: 'boolean',
207+
defaultValue: false,
208+
advanced: true,
209+
},
210+
{
211+
name: 'focusOnSelect',
212+
helperText: 'Focus on slide after slide change for better accessibility',
213+
type: 'boolean',
214+
defaultValue: false,
215+
advanced: true,
216+
},
203217
],
204218
};

packages/widgets/src/components/Carousel.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ interface CarouselProps {
2525
useChildrenForSlides?: boolean;
2626
slickProps?: Settings;
2727
responsive?: ResponsiveObject[];
28+
accessibility?: boolean;
29+
focusOnSelect?: boolean;
2830
}
2931

3032
// TODO: change to slick grid
@@ -100,6 +102,8 @@ export class CarouselComponent extends React.Component<CarouselProps> {
100102
this.props.autoplaySpeed ? this.props.autoplaySpeed * 1000 : undefined
101103
}
102104
dots={!this.props.hideDots}
105+
accessibility={this.props.accessibility}
106+
focusOnSelect={this.props.focusOnSelect}
103107
// TODO: on change emit event on element?
104108
// renderBottomCenterControls={this.props.hideDots ? () => null : undefined}
105109

0 commit comments

Comments
 (0)