fix Modal typo and refactor BaseDialog to fix " undefined" className
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
7f1ce52dd3
commit
d8a1feb501
2 changed files with 16 additions and 9 deletions
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import FocusTrap from 'focus-trap-react';
|
import FocusTrap from 'focus-trap-react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { MatrixClient } from 'matrix-js-sdk';
|
import { MatrixClient } from 'matrix-js-sdk';
|
||||||
|
|
||||||
|
@ -64,7 +65,10 @@ export default React.createClass({
|
||||||
|
|
||||||
// Id of content element
|
// Id of content element
|
||||||
// If provided, this is used to add a aria-describedby attribute
|
// If provided, this is used to add a aria-describedby attribute
|
||||||
contentId: React.PropTypes.string,
|
contentId: PropTypes.string,
|
||||||
|
|
||||||
|
// optional additional class for the title element
|
||||||
|
titleClass: PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -105,25 +109,28 @@ export default React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
const TintableSvg = sdk.getComponent("elements.TintableSvg");
|
const TintableSvg = sdk.getComponent("elements.TintableSvg");
|
||||||
|
|
||||||
|
let cancelButton;
|
||||||
|
if (this.props.hasCancel) {
|
||||||
|
cancelButton = <AccessibleButton onClick={this._onCancelClick} className="mx_Dialog_cancelButton">
|
||||||
|
<TintableSvg src="img/icons-close-button.svg" width="35" height="35" />
|
||||||
|
</AccessibleButton>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FocusTrap onKeyDown={this._onKeyDown}
|
<FocusTrap onKeyDown={this._onKeyDown}
|
||||||
className={this.props.className}
|
className={this.props.className}
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-labelledby='mx_BaseDialog_title'
|
aria-labelledby='mx_BaseDialog_title'
|
||||||
// This should point to a node describing the dialog.
|
// This should point to a node describing the dialog.
|
||||||
// If we were about to completelly follow this recommendation we'd need to
|
// If we were about to completely follow this recommendation we'd need to
|
||||||
// make all the components relying on BaseDialog to be aware of it.
|
// make all the components relying on BaseDialog to be aware of it.
|
||||||
// So instead we will use the whole content as the description.
|
// So instead we will use the whole content as the description.
|
||||||
// Description comes first and if the content contains more text,
|
// Description comes first and if the content contains more text,
|
||||||
// AT users can skip its presentation.
|
// AT users can skip its presentation.
|
||||||
aria-describedby={this.props.contentId}
|
aria-describedby={this.props.contentId}
|
||||||
>
|
>
|
||||||
{ this.props.hasCancel ? <AccessibleButton onClick={this._onCancelClick}
|
{ cancelButton }
|
||||||
className="mx_Dialog_cancelButton"
|
<div className={classNames('mx_Dialog_title', this.props.titleClass)} id='mx_BaseDialog_title'>
|
||||||
>
|
|
||||||
<TintableSvg src="img/icons-close-button.svg" width="35" height="35" />
|
|
||||||
</AccessibleButton> : null }
|
|
||||||
<div className={'mx_Dialog_title ' + this.props.titleClass} id='mx_BaseDialog_title'>
|
|
||||||
{ this.props.title }
|
{ this.props.title }
|
||||||
</div>
|
</div>
|
||||||
{ this.props.children }
|
{ this.props.children }
|
||||||
|
|
|
@ -187,7 +187,7 @@ export default class ChatCreateOrReuseDialog extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatCreateOrReuseDialog.propTyps = {
|
ChatCreateOrReuseDialog.propTypes = {
|
||||||
userId: PropTypes.string.isRequired,
|
userId: PropTypes.string.isRequired,
|
||||||
// Called when clicking outside of the dialog
|
// Called when clicking outside of the dialog
|
||||||
onFinished: PropTypes.func.isRequired,
|
onFinished: PropTypes.func.isRequired,
|
||||||
|
|
Loading…
Reference in a new issue