Skip to content

Commit

Permalink
fix(list): Only apply aria-orientation with role (#945)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

'orientation` is now used instead of 'aria-orientation' to specify list orientation.
This allows smarter aria defaults that can be overridden if needed.
  • Loading branch information
liamcmitchell-sc authored and Matt Goo committed Jul 12, 2019
1 parent a41d0c7 commit beab319
Show file tree
Hide file tree
Showing 35 changed files with 140 additions and 74 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# [](https://github.com/material-components/material-components-web-react/compare/v0.13.2...v) (2019-06-25)
# [0.14.1](https://github.com/material-components/material-components-web-react/compare/v0.14.0...v0.14.1) (2019-07-02)


### Bug Fixes

* **infrastructure:** fix SSR support for webpack4 update ([#956](https://github.com/material-components/material-components-web-react/issues/956)) ([5d3a89d](https://github.com/material-components/material-components-web-react/commit/5d3a89d))



# [0.14.0](https://github.com/material-components/material-components-web-react/compare/v0.13.2...v0.14.0) (2019-06-25)


### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"packages": [
"packages/*"
],
"version": "0.14.0"
"version": "0.14.1"
}
4 changes: 2 additions & 2 deletions packages/button/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-button",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Button",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -21,7 +21,7 @@
},
"dependencies": {
"@material/button": "^1.1.0",
"@material/react-ripple": "^0.14.0",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/card/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-card",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Card",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -21,7 +21,7 @@
},
"dependencies": {
"@material/card": "^2.1.1",
"@material/react-ripple": "^0.14.0",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/checkbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-checkbox",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Checkbox",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -20,7 +20,7 @@
},
"dependencies": {
"@material/checkbox": "^2.1.1",
"@material/react-ripple": "^0.14.0",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/chips/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-chips",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Chips",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -23,7 +23,7 @@
},
"dependencies": {
"@material/chips": "^2.3.0",
"@material/react-ripple": "^0.14.0",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6",
"react-is": "^16.8.6"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/dialog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-dialog",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Dialog",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -21,7 +21,7 @@
"dependencies": {
"@material/dialog": "^2.2.0",
"@material/dom": "^1.0.0",
"@material/react-button": "^0.14.0",
"@material/react-button": "^0.14.1",
"classnames": "^2.2.6",
"focus-trap": "^5.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/drawer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-drawer",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Drawer",
"license": "MIT",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/fab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-fab",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Floating Action Button (FAB)",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -21,7 +21,7 @@
},
"dependencies": {
"@material/fab": "^2.1.1",
"@material/react-ripple": "^0.14.0",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/floating-label/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-floating-label",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Floating Label",
"license": "MIT",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/icon-button/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-icon-button",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Icon Button",
"license": "Apache-2.0",
"main": "dist/index.js",
Expand All @@ -21,7 +21,7 @@
},
"dependencies": {
"@material/icon-button": "^2.1.1",
"@material/react-ripple": "^0.14.0",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/layout-grid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-layout-grid",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Layout Grid",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/line-ripple/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-line-ripple",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Line Ripple",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/linear-progress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-linear-progress",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Linear Progress",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class MyApp extends Component {
| radioList | Boolean | Set the list to act as a radio list |
| selectedIndex | Number | Array<Number> | Toggles the selected state of the list item at the given index. Behaves differently for checkboxList and radioList (see sections above for more detail). |
| handleSelect | Function(activatedItemIndex: Number, selected: Number | Array<Number>) => void | Callback for handling a list item selection event. `selected` will be an Array,Number> for checkbox lists. |
| aria-orientation | String | Indicates the list orientation |
| orientation | `'vertical'` \| `'horizontal'` | Indicates the list orientation (defaults to `'vertical'`). |
| tag | String | Customizes the list tag type (defaults to `'ul'`) |

### ListItem
Expand Down
24 changes: 18 additions & 6 deletions packages/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import ListItemMeta from './ListItemMeta';
import ListDivider from './ListDivider';
import ListGroup from './ListGroup';
import ListGroupSubheader from './ListGroupSubheader';
const ARIA_ORIENTATION = 'aria-orientation';
const VERTICAL = 'vertical';

const HORIZONTAL = 'horizontal';

export interface ListProps extends React.HTMLProps<HTMLElement> {
className?: string;
Expand All @@ -52,6 +52,7 @@ export interface ListProps extends React.HTMLProps<HTMLElement> {
wrapFocus?: boolean;
tag?: string;
ref?: React.Ref<any>;
orientation?: 'vertical' | 'horizontal';
}

interface ListState {
Expand Down Expand Up @@ -114,7 +115,6 @@ export default class List extends React.Component<ListProps, ListState> {
selectedIndex: -1,
handleSelect: () => {},
wrapFocus: true,
'aria-orientation': VERTICAL,
tag: 'ul',
};

Expand All @@ -128,8 +128,9 @@ export default class List extends React.Component<ListProps, ListState> {
this.foundation.setSelectedIndex(selectedIndex);
}
this.foundation.setWrapFocus(wrapFocus!);
// Vertical is the default so true unless explicitly horizontal.
this.foundation.setVerticalOrientation(
this.props[ARIA_ORIENTATION] === VERTICAL
this.props.orientation !== HORIZONTAL
);
this.initializeListType();
}
Expand All @@ -146,9 +147,9 @@ export default class List extends React.Component<ListProps, ListState> {
if (wrapFocus !== prevProps.wrapFocus) {
this.foundation.setWrapFocus(wrapFocus!);
}
if (this.props[ARIA_ORIENTATION] !== prevProps[ARIA_ORIENTATION]) {
if (this.props.orientation !== prevProps.orientation) {
this.foundation.setVerticalOrientation(
this.props[ARIA_ORIENTATION] === VERTICAL
this.props.orientation !== HORIZONTAL
);
}
}
Expand Down Expand Up @@ -422,6 +423,7 @@ export default class List extends React.Component<ListProps, ListState> {
/* eslint-enable @typescript-eslint/no-unused-vars */
children,
tag: Tag,
orientation,
...otherProps
} = this.props;

Expand All @@ -432,6 +434,16 @@ export default class List extends React.Component<ListProps, ListState> {
className={this.classes}
ref={this.listElement}
role={this.role}
// Only specify aria-orientation if:
// - orientation is horizontal (vertical is implicit)
// - props.role is falsy (not overridden)
// - this.role is truthy (we are applying role for checkboxList/radiogroup that supports aria-orientation)
// https://github.com/material-components/material-components-web/tree/master/packages/mdc-list#accessibility
aria-orientation={
orientation === HORIZONTAL && !role && this.role
? HORIZONTAL
: undefined
}
{...otherProps}
>
<ListItemContext.Provider
Expand Down
8 changes: 4 additions & 4 deletions packages/list/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-list",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React List",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -21,9 +21,9 @@
"dependencies": {
"@material/dom": "^1.1.0",
"@material/list": "^1.0.0",
"@material/react-checkbox": "^0.14.0",
"@material/react-radio": "^0.14.0",
"@material/react-ripple": "^0.14.0",
"@material/react-checkbox": "^0.14.1",
"@material/react-radio": "^0.14.1",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6",
"memoize-one": "^5.0.4"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/material-icon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-material-icon",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Material Icon",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -20,7 +20,7 @@
"react": "^16.4.2"
},
"dependencies": {
"@material/react-ripple": "^0.14.0",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/menu-surface/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-menu-surface",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Menu Surface",
"license": "MIT",
"main": "dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/menu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-menu",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Menu",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -20,8 +20,8 @@
},
"dependencies": {
"@material/menu": "^1.1.0",
"@material/react-list": "^0.14.0",
"@material/react-menu-surface": "^0.14.0",
"@material/react-list": "^0.14.1",
"@material/react-menu-surface": "^0.14.1",
"classnames": "^2.2.6"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/notched-outline/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-notched-outline",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Componens React Notched Outline",
"license": "MIT",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/radio/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-radio",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Componens React Radio",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -21,7 +21,7 @@
"dependencies": {
"@material/form-field": "^0.41.0",
"@material/radio": "^1.1.0",
"@material/react-ripple": "^0.14.0",
"@material/react-ripple": "^0.14.1",
"classnames": "^2.2.6"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-ripple",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Ripple",
"license": "MIT",
"main": "dist/index.js",
Expand Down
12 changes: 6 additions & 6 deletions packages/select/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-select",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Select",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -19,11 +19,11 @@
"react": "^16.4.2"
},
"dependencies": {
"@material/react-floating-label": "^0.14.0",
"@material/react-line-ripple": "^0.14.0",
"@material/react-menu": "^0.14.0",
"@material/react-menu-surface": "^0.14.0",
"@material/react-notched-outline": "^0.14.0",
"@material/react-floating-label": "^0.14.1",
"@material/react-line-ripple": "^0.14.1",
"@material/react-menu": "^0.14.1",
"@material/react-menu-surface": "^0.14.1",
"@material/react-notched-outline": "^0.14.1",
"@material/select": "^1.1.1",
"classnames": "^2.2.6"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/snackbar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@material/react-snackbar",
"version": "0.14.0",
"version": "0.14.1",
"description": "Material Components React Snackbar",
"license": "MIT",
"main": "dist/index.js",
Expand Down
Loading

0 comments on commit beab319

Please sign in to comment.