Skip to content

Commit 7bd9355

Browse files
Added better aira controls
1 parent b781093 commit 7bd9355

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

more-list.jsx

+6-9
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ var MoreList = React.createClass({
6464
allowShowAll: false,
6565
showCount: true
6666
};
67-
},
68-
generateMessage: function(increment) {
69-
7067
},
7168
addMoreComponent: function() {
7269
var children = this.props.children;
@@ -80,7 +77,7 @@ var MoreList = React.createClass({
8077

8178
if(this.props.moreSize === 0) {
8279
var count = this.props.showCount ? <span className="ml-count ml-more-count">{remaining}</span> : null;
83-
return (<li aria-label={message} role="button" className="ml-list-item ml-expander ml-more" onMouseDown={this.increaseItemsShown.bind(this, remaining)}>More... {count}</li>);
80+
return (<li aria-label={message} aria-controls={this.props.id} role="button" className="ml-list-item ml-expander ml-more" onMouseDown={this.increaseItemsShown.bind(this, remaining)}>More... {count}</li>);
8481
}
8582

8683
var toAdd = remaining <= this.props.moreSize ? remaining : this.props.moreSize;
@@ -94,7 +91,7 @@ var MoreList = React.createClass({
9491
message = "Click to show " + toAdd + " more items";
9592
}
9693

97-
return (<li aria-label={message} role="button" className="ml-list-item ml-expander ml-more" onMouseDown={this.increaseItemsShown.bind(this, toAdd)}>More... {count}</li>);
94+
return (<li aria-label={message} aria-controls={this.props.id} role="button" className="ml-list-item ml-expander ml-more" onMouseDown={this.increaseItemsShown.bind(this, toAdd)}>More... {count}</li>);
9895
},
9996
addShowAllComponent: function() {
10097
if(!this.props.allowShowAll || this.props.moreSize == 0) {
@@ -111,7 +108,7 @@ var MoreList = React.createClass({
111108
var message = "Click to show all " + remaining + " remaining items";
112109

113110
var count = this.props.showCount ? <span className="ml-count ml-show-all-count">{remaining}</span> : null;
114-
return (<li aria-label={message} role="button" className="ml-list-item ml-expander ml-show-all" onMouseDown={this.increaseItemsShown.bind(this, remaining)}>Show All... {count}</li>);
111+
return (<li aria-label={message} aria-controls={this.props.id} role="button" className="ml-list-item ml-expander ml-show-all" onMouseDown={this.increaseItemsShown.bind(this, remaining)}>Show All... {count}</li>);
115112
},
116113
render: function()
117114
{
@@ -124,21 +121,21 @@ var MoreList = React.createClass({
124121
var shownItemCount = this.state.itemsShown;
125122
shownItemCount += shownItemCount + this.props.tolerance >= children.length ? this.props.tolerance : 0;
126123

127-
var listItems = children.slice(0, shownItemCount).map(function (child) {
124+
var listItems = children.slice(0, shownItemCount).map(function (child, id) {
128125
var className = "ml-list-item ml-data"
129126

130127
if(child.props.className) {
131128
className = className + " " + child.props.className;
132129
}
133130

134-
return React.addons.cloneWithProps(child, { className: className})
131+
return React.addons.cloneWithProps(child, { className: className, ref: "li" + id})
135132
});
136133

137134
listItems.push(this.addMoreComponent());
138135
listItems.push(this.addShowAllComponent());
139136

140137
return (
141-
<ul className="ml-list">
138+
<ul aria-live="assertive" className="ml-list">
142139
{listItems}
143140
</ul>
144141
)

sample.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var MoreList = require("./more-list.jsx");
33
require("./more-list-styles.css");
44

55
React.render(
6-
<MoreList>
6+
<MoreList id="fruits">
77
<li>Apple</li>
88
<li>Banana</li>
99
<li>Coconut</li>

0 commit comments

Comments
 (0)