Skip to content

Allow accessibility attributes on the root element #114

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

Merged
merged 8 commits into from
Oct 24, 2016

Conversation

adamschroder
Copy link
Contributor

@adamschroder adamschroder commented Sep 29, 2016

Hi there! I found some issues with this component in terms of accessibility. Particularly in how the Windows Narrator announces the Modal. From the spec , the aria-labelledby or aria-label should be an attribute on the same element as the role=dialog.

Additionally, it would fit more use cases if the dialog could also be an alertdialog (or anything else that could also make sense, semantically).

If there are styling, formatting, or any other issues with this PR please let me know & i'd be happy to make them.

@jquense
Copy link
Member

jquense commented Sep 29, 2016

Hi there, thanks for the PR. I think a more straightforward and flexible strategy here is to forward all the props (less the Modal.propTypes) to the component. Then there is no need for a whitelist.

{ backdrop && this.renderBackdrop() }
{ dialog }
</div>
{React.createElement('div',
Copy link
Member

@jquense jquense Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this back to jsx?

@@ -267,20 +275,27 @@ const Modal = React.createClass({
);
}

const modalProps = Object.assign(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of the whitelist you can do something like elementProps = _.omit(this.props, Object.keys(Modal.PropTypes))

expect(attr).to.equal('modal-description');
});

it('Should accept the `tabIndex` property on the Modal', function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should accept a tab index here, that would screw up the focus management. We already ensure that the dialog component has a tabIndex for a11y

@jquense
Copy link
Member

jquense commented Sep 29, 2016

Hmm there are a bunch of inconsistencies with how we manage roles here that I hadn't noticed before, in connection with the react-bootstrap modal. I need to think a bit on what might be the best way to move forward to fix them tho (pre-existing issues to your PR here)

@adamschroder
Copy link
Contributor Author

@jquense thanks for being so quick to review this PR. I've made your suggested changes, and I also took a stab at fixing some of the tests. Let me know of any other feedback.

@adamschroder
Copy link
Contributor Author

Not sure why the tests are failing on Travis, they are passing locally. Any ideas?

const propTypes = Object.keys(Modal.propTypes);
const newProps = {};
keys.map(function (prop) {
if (!propTypes.includes(prop)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array.prototype.includes is not available in all browsers. That's why tests are failing. Separately this should be an arrow function though. Even more separately this should just be what @jquense said with _.omit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @taion, great catch. I didn't use _.omit because lodash is just a dev dependency in this project, and I didn't want to add it just for this. If ya'll are ok with adding it, i'll happily change the code.

@taion
Copy link
Member

taion commented Oct 4, 2016

@jquense Are your concerns regarding the pre-existing issues blockers for this PR?

@adamschroder
Copy link
Contributor Author

Hey guys, whats the status on this PR?

@adamschroder
Copy link
Contributor Author

hey @jquense, it has been a little over 2 weeks since there was any feedback here, any updates?

if (propTypes.indexOf(prop) === -1) {
newProps[prop] = _props[prop];
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you hoist this out of hte render method as an omitProps function just so its a bit clearer what's going on?

@jquense
Copy link
Member

jquense commented Oct 17, 2016

i guess this is ok as is for now, could you also rebase the branch against master so it's a bit cleaner

thanks!

@adamschroder
Copy link
Contributor Author

Updated & rebased. Thanks for the attention and feedback!

@@ -211,6 +211,19 @@ const Modal = React.createClass({
};
},

omitProps(props, desiredProps) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pass in the propTypes object here, and check Object.prototype.hasOwnProperty.call

@taion
Copy link
Member

taion commented Oct 17, 2016

ping @jquense

@adamschroder
Copy link
Contributor Author

Hey guys, sorry for the spam, but can we try to get this merged?

@jquense jquense merged commit 6090354 into react-bootstrap:master Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants