Skip to content

Commit

Permalink
squash: use labelledby and describy for advance settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ghassanmas committed Jul 19, 2024
1 parent fadcc6a commit f56f44b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/advanced-settings/AdvancedSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ const AdvancedSettings = ({ intl, courseId }) => {
<AlertMessage
show={saveSettingsPrompt}
aria-hidden={saveSettingsPrompt}
aria-label={intl.formatMessage(messages.alertWarning)}
aria-description={intl.formatMessage(messages.alertWarningDescriptions)}
aria-labelledby="advancedSettingsAlertWarningTitle"
aria-describedby="advancedSettingsAlertWarningDesc"
role="dialog"
actions={[
!isQueryPending && (
Expand All @@ -261,7 +261,9 @@ const AdvancedSettings = ({ intl, courseId }) => {
variant="warning"
icon={Warning}
title={intl.formatMessage(messages.alertWarning)}
titleId="advancedSettingsAlertWarningTitle"
description={intl.formatMessage(messages.alertWarningDescriptions)}
descriptoinId="advancedSettingsAlertWarningDesc"
/>
</div>
<ModalError
Expand Down
12 changes: 9 additions & 3 deletions src/generic/alert-message/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@ import React from 'react';
import { Alert } from '@openedx/paragon';
import PropTypes from 'prop-types';

const AlertMessage = ({ title, description, ...props }) => (
const AlertMessage = ({
title, titleId, description, descriptoinId, ...props
}) => (
<Alert {...props}>
<Alert.Heading>{title}</Alert.Heading>
<span>{description}</span>
<Alert.Heading id={titleId}>{title}</Alert.Heading>
<span id={descriptoinId}>{description}</span>
</Alert>
);

AlertMessage.propTypes = {
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
titleId: PropTypes.string,
description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
descriptoinId: PropTypes.string,
};

AlertMessage.defaultProps = {
title: undefined,
titleId: undefined,
description: undefined,
descriptoinId: undefined,
};

export default AlertMessage;

0 comments on commit f56f44b

Please sign in to comment.