Skip to content

Commit a2bb5f6

Browse files
authored
fix(ObjectStatus): add screen reader announcement for inactive state (#5204)
1 parent c27da9b commit a2bb5f6

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

packages/main/src/components/ObjectStatus/ObjectStatus.cy.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ describe('ObjectStatus', () => {
234234
cy.findByText('Content').click();
235235
cy.get('@clickSpy').should('not.be.called');
236236
cy.findByRole('button').should('not.exist');
237-
cy.findByTestId('os').should('not.have.attr', 'aria-roledescription');
237+
cy.findByText('Object Status').should('exist').and('not.be.visible');
238238

239239
cy.mount(
240240
<ObjectStatus onClick={click} active>
@@ -243,14 +243,14 @@ describe('ObjectStatus', () => {
243243
);
244244
cy.findByText('Content').click();
245245
cy.get('@clickSpy').should('have.been.calledOnce');
246-
cy.findByRole('button').should('have.attr', 'aria-roledescription', 'Object Status Button');
246+
cy.findByText('Object Status Button').should('exist').and('not.be.visible');
247247
});
248248

249249
it('emptyIndicator', () => {
250250
cy.mount(<ObjectStatus data-testid="os" />);
251-
cy.findByTestId('os').children().should('have.length', 0);
252-
cy.mount(<ObjectStatus data-testid="os" emptyIndicator />);
253251
cy.findByTestId('os').children().should('have.length', 1);
252+
cy.mount(<ObjectStatus data-testid="os" emptyIndicator />);
253+
cy.findByTestId('os').children().should('have.length', 2);
254254
cy.findByText('–').should('be.visible');
255255
});
256256

packages/main/src/components/ObjectStatus/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ import React, { forwardRef } from 'react';
1717
import { createUseStyles } from 'react-jss';
1818
import type { IndicationColor } from '../../enums/index.js';
1919
import { ValueState } from '../../enums/index.js';
20-
import { ARIA_OBJ_STATUS_DESC, EMPTY_VALUE, INDICATION_COLOR } from '../../i18n/i18n-defaults.js';
20+
import {
21+
ARIA_OBJ_STATUS_DESC,
22+
ARIA_OBJ_STATUS_DESC_INACTIVE,
23+
EMPTY_VALUE,
24+
INDICATION_COLOR
25+
} from '../../i18n/i18n-defaults.js';
2126
import type { CommonProps } from '../../interfaces/index.js';
2227
import { Icon } from '../../webComponents/Icon/index.js';
2328
import styles from './ObjectStatus.jss.js';
@@ -210,10 +215,12 @@ const ObjectStatus = forwardRef<HTMLDivElement, ObjectStatusPropTypes>((props, r
210215
onClick={active ? onClick : undefined}
211216
tabIndex={active ? 0 : undefined}
212217
data-icon-only={!children}
213-
role={active ? 'button' : undefined}
214-
aria-roledescription={active ? i18nBundle.getText(ARIA_OBJ_STATUS_DESC) : undefined}
218+
role={active ? 'button' : 'group'}
215219
{...rest}
216220
>
221+
<span className={classes.pseudoInvisibleText} data-component-name="ObjectStatusInvisibleDescriptionContainer">
222+
{active ? i18nBundle.getText(ARIA_OBJ_STATUS_DESC) : i18nBundle.getText(ARIA_OBJ_STATUS_DESC_INACTIVE)}
223+
</span>
217224
{iconToRender && (
218225
<span className={classes.icon} data-icon-only={!children} data-component-name="ObjectStatusIconContainer">
219226
{iconToRender}

packages/main/src/i18n/messagebundle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,12 @@ NUMERICCONTENT_DEVIATION_UP=Ascending
273273
#XTOL: Tooltip Numeric Content Deviation Down
274274
NUMERICCONTENT_DEVIATION_DOWN=Descending
275275

276-
#XACT: Aria role description for ObjectStatus component
276+
#XACT: Aria role description for active ObjectStatus component
277277
ARIA_OBJ_STATUS_DESC=Object Status Button
278278

279+
#XACT: Aria role description for inactive ObjectStatus component
280+
ARIA_OBJ_STATUS_DESC_INACTIVE=Object Status
281+
279282
#XACT: Invisible text for ObjectStatus indication color
280283
INDICATION_COLOR=Indication Color
281284

0 commit comments

Comments
 (0)