Skip to content
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class AboutModal extends React.Component {
static propTypes = propTypes;
static defaultProps = defaultProps;

ariaLabelledbyId = `pf-about-modal-title-${currentId++}`;
ariaDescribedById = `pf-about-modal-content-${currentId++}`;
ariaLabelledBy = `pf-about-modal-title-${currentId++}`;
ariaDescribedBy = `pf-about-modal-content-${currentId++}`;

handleEscKeyClick = event => {
if (event.keyCode === KEY_CODES.ESCAPE_KEY && this.props.isOpen) {
Expand Down Expand Up @@ -96,8 +96,8 @@ class AboutModal extends React.Component {
return ReactDOM.createPortal(
<AboutModalContainer
{...this.props}
ariaLabelledbyId={this.ariaLabelledbyId}
ariaDescribedById={this.ariaDescribedById}
aria-labelledby={this.ariaLabelledBy}
aria-describedby={this.ariaDescribedBy}
/>,
this.container
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ test('modal does not call onClose for esc key if it is not open', () => {
expect(props.onClose).not.toBeCalled();
});

test('Each modal is given new ariaDescribedById and ariaLablledbyId', () => {
test('Each modal is given new aria-describedby and aria-lablledby', () => {
Comment thread
redallen marked this conversation as resolved.
Outdated
const first = shallow(<AboutModal {...props}> Test About Modal </AboutModal>);
const second = shallow(<AboutModal {...props}> Test About Modal </AboutModal>);
expect(first.props().ariaLabelledbyId).not.toBe(second.props().ariaLabelledbyId);
expect(first.props().ariaDescribedById).not.toBe(second.props().ariaDescribedById);
expect(first.props()['aria-labelledby']).not.toBe(second.props()['aria-labelledby']);
expect(first.props()['aria-describedby']).not.toBe(second.props()['aria-describedby']);
});

test('Console error is generated when the logoImageSrc is provided without logoImageAlt', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const propTypes = {
/** the alternate text of the Logo image. */
logoImageAlt: PropTypes.string.isRequired,
/** id to use for About Modal Box aria labeled by */
ariaLabelledbyId: PropTypes.string.isRequired,
'aria-labelledby': PropTypes.string.isRequired,
/** id to use for About Modal Box aria described by */
ariaDescribedById: PropTypes.string.isRequired,
'aria-describedby': PropTypes.string.isRequired,
/** Additional props are spread to the AboutModalBoxContent component */
'': PropTypes.any
};
Expand All @@ -55,8 +55,8 @@ const ModalContent = ({
brandImageAlt,
logoImageSrc,
logoImageAlt,
ariaLabelledbyId,
ariaDescribedById,
'aria-labelledby': ariaLabelledBy,
'aria-describedby': ariaDescribedBy,
...props
}) => {
if (!isOpen) {
Expand All @@ -65,11 +65,11 @@ const ModalContent = ({
return (
<Backdrop>
<Bullseye>
<AboutModalBox className={className} aria-labelledby={ariaLabelledbyId} aria-describedby={ariaDescribedById}>
<AboutModalBox className={className} aria-labelledby={ariaLabelledBy} aria-describedby={ariaDescribedBy}>
<AboutModalBoxBrand src={brandImageSrc} alt={brandImageAlt} />
<AboutModalBoxCloseButton onClose={onClose} />
<AboutModalBoxHeader id={ariaLabelledbyId} productName={productName} />
<AboutModalBoxContent {...props} trademark={trademark} id={ariaDescribedById}>
<AboutModalBoxHeader id={ariaLabelledBy} productName={productName} />
<AboutModalBoxContent {...props} trademark={trademark} id={ariaDescribedBy}>
{children}
</AboutModalBoxContent>
<AboutModalBoxHero />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const props = {
brandImageAlt: 'Brand Image',
logoImageSrc: 'logoImg...',
logoImageAlt: 'AboutModal Logo',
ariaLabelledbyId: 'ariaLablledbyId',
ariaDescribedById: 'ariaDescribedById'
'aria-labelledby': 'ariaLabelledBy',
'aria-describedby': 'ariaDescribedBy'
};
test('About Modal Container Test simple', () => {
const view = shallow(<AboutModalContainer {...props}>This is ModalBox content</AboutModalContainer>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ exports[`About Modal Container Test isOpen 1`] = `
component="div"
>
<AboutModalBox
aria-describedby="ariaDescribedById"
aria-labelledby="ariaLablledbyId"
aria-describedby="ariaDescribedBy"
aria-labelledby="ariaLabelledBy"
className=""
>
<AboutModalBoxBrand
Expand All @@ -24,12 +24,12 @@ exports[`About Modal Container Test isOpen 1`] = `
/>
<AboutModalBoxHeader
className=""
id="ariaLablledbyId"
id="ariaLabelledBy"
productName="Product Name"
/>
<AboutModalBoxContent
className=""
id="ariaDescribedById"
id="ariaDescribedBy"
title="Test Modal Container title"
trademark="Trademark and copyright information here"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ const Alert = ({
</div>
)}
{action && (
<div className={css(styles.alertAction, className)}>{React.cloneElement(action, { title, variantLabel })}</div>
<div className={css(styles.alertAction, className)}>
{React.cloneElement(action, { title, variantLabel })}
</div>
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const defaultProps = {
onClose: () => undefined
};

const AlertActionCloseButton = ({ className, onClose, 'aria-label': ariaLabel, title, variantLabel, ...props }) => (
const AlertActionCloseButton = ({ className, onClose, variantLabel, 'aria-label': ariaLabel, title, variant, ...props }) => (
Comment thread
redallen marked this conversation as resolved.
Outdated
<Button
variant={ButtonVariant.plain}
onClick={onClose}
aria-label={ariaLabel === '' ? `Close ${variantLabel} alert: ${title}` : ariaLabel}
aria-label={ariaLabel === '' ? `Close ${variant} alert: ${title}` : ariaLabel}
{...props}
>
<TimesIcon />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const defaultProps = {
className: ''
};

const AlertActionLink = ({ className, children, ...props }) => (
const AlertActionLink = ({ className, variantLabel, children, ...props }) => (
<Button variant={ButtonVariant.link} {...props}>
{children}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ const propTypes = {
children: PropTypes.node,
className: PropTypes.string,
onClose: PropTypes.func,
closeButtonAriaLabel: PropTypes.string
'aria-label': PropTypes.string
};

const defaultProps = {
title: null,
children: '',
className: '',
onClose: undefined,
closeButtonAriaLabel: 'Close'
'aria-label': 'Close'
};

const AlertBody = ({ title, className, children, onClose, closeButtonAriaLabel, ...props }) => (
const AlertBody = ({ title, className, children, onClose, 'aria-label': ariaLabel, ...props }) => (
<div {...props} className={className}>
{onClose && (
<Button variant={ButtonVariant.plain} onClick={onClose} aria-label={closeButtonAriaLabel}>
<Button variant={ButtonVariant.plain} onClick={onClose} aria-label={ariaLabel}>
<TimesIcon />
</Button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ exports[`Alert - danger Action Link 1`] = `
title=""
type="button"
variant="link"
variantLabel="Danger"
>
<button
aria-disabled={null}
Expand All @@ -231,7 +230,6 @@ exports[`Alert - danger Action Link 1`] = `
tabIndex={null}
title=""
type="button"
variantLabel="Danger"
>
test
</button>
Expand Down Expand Up @@ -331,7 +329,6 @@ exports[`Alert - danger Action and Title 1`] = `
title="Some title"
type="button"
variant="link"
variantLabel="Danger"
>
<button
aria-disabled={null}
Expand All @@ -341,7 +338,6 @@ exports[`Alert - danger Action and Title 1`] = `
tabIndex={null}
title="Some title"
type="button"
variantLabel="Danger"
>
test
</button>
Expand Down Expand Up @@ -442,7 +438,6 @@ exports[`Alert - danger Custom aria label 1`] = `
title="Some title"
type="button"
variant="link"
variantLabel="Danger"
>
<button
aria-disabled={null}
Expand All @@ -452,7 +447,6 @@ exports[`Alert - danger Custom aria label 1`] = `
tabIndex={null}
title="Some title"
type="button"
variantLabel="Danger"
>
test
</button>
Expand Down Expand Up @@ -817,7 +811,6 @@ exports[`Alert - info Action Link 1`] = `
title=""
type="button"
variant="link"
variantLabel="Info"
>
<button
aria-disabled={null}
Expand All @@ -827,7 +820,6 @@ exports[`Alert - info Action Link 1`] = `
tabIndex={null}
title=""
type="button"
variantLabel="Info"
>
test
</button>
Expand Down Expand Up @@ -927,7 +919,6 @@ exports[`Alert - info Action and Title 1`] = `
title="Some title"
type="button"
variant="link"
variantLabel="Info"
>
<button
aria-disabled={null}
Expand All @@ -937,7 +928,6 @@ exports[`Alert - info Action and Title 1`] = `
tabIndex={null}
title="Some title"
type="button"
variantLabel="Info"
>
test
</button>
Expand Down Expand Up @@ -1038,7 +1028,6 @@ exports[`Alert - info Custom aria label 1`] = `
title="Some title"
type="button"
variant="link"
variantLabel="Info"
>
<button
aria-disabled={null}
Expand All @@ -1048,7 +1037,6 @@ exports[`Alert - info Custom aria label 1`] = `
tabIndex={null}
title="Some title"
type="button"
variantLabel="Info"
>
test
</button>
Expand Down Expand Up @@ -1413,7 +1401,6 @@ exports[`Alert - success Action Link 1`] = `
title=""
type="button"
variant="link"
variantLabel="Success"
>
<button
aria-disabled={null}
Expand All @@ -1423,7 +1410,6 @@ exports[`Alert - success Action Link 1`] = `
tabIndex={null}
title=""
type="button"
variantLabel="Success"
>
test
</button>
Expand Down Expand Up @@ -1523,7 +1509,6 @@ exports[`Alert - success Action and Title 1`] = `
title="Some title"
type="button"
variant="link"
variantLabel="Success"
>
<button
aria-disabled={null}
Expand All @@ -1533,7 +1518,6 @@ exports[`Alert - success Action and Title 1`] = `
tabIndex={null}
title="Some title"
type="button"
variantLabel="Success"
>
test
</button>
Expand Down Expand Up @@ -1634,7 +1618,6 @@ exports[`Alert - success Custom aria label 1`] = `
title="Some title"
type="button"
variant="link"
variantLabel="Success"
>
<button
aria-disabled={null}
Expand All @@ -1644,7 +1627,6 @@ exports[`Alert - success Custom aria label 1`] = `
tabIndex={null}
title="Some title"
type="button"
variantLabel="Success"
>
test
</button>
Expand Down Expand Up @@ -2009,7 +1991,6 @@ exports[`Alert - warning Action Link 1`] = `
title=""
type="button"
variant="link"
variantLabel="Warning"
>
<button
aria-disabled={null}
Expand All @@ -2019,7 +2000,6 @@ exports[`Alert - warning Action Link 1`] = `
tabIndex={null}
title=""
type="button"
variantLabel="Warning"
>
test
</button>
Expand Down Expand Up @@ -2119,7 +2099,6 @@ exports[`Alert - warning Action and Title 1`] = `
title="Some title"
type="button"
variant="link"
variantLabel="Warning"
>
<button
aria-disabled={null}
Expand All @@ -2129,7 +2108,6 @@ exports[`Alert - warning Action and Title 1`] = `
tabIndex={null}
title="Some title"
type="button"
variantLabel="Warning"
>
test
</button>
Expand Down Expand Up @@ -2230,7 +2208,6 @@ exports[`Alert - warning Custom aria label 1`] = `
title="Some title"
type="button"
variant="link"
variantLabel="Warning"
>
<button
aria-disabled={null}
Expand All @@ -2240,7 +2217,6 @@ exports[`Alert - warning Custom aria label 1`] = `
tabIndex={null}
title="Some title"
type="button"
variantLabel="Warning"
>
test
</button>
Expand Down
Loading