Skip to content

Commit 34d4a39

Browse files
authored
fix(ExpandableText): announce state of "Show More" button correctly with screen readers (#5836)
1 parent 954c627 commit 34d4a39

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ describe('ExpandableText', () => {
6565
{longText}
6666
</ExpandableText>
6767
);
68-
cy.findByText('Show more').click();
68+
cy.findByText('Show more').should('have.attr', 'accessible-name', 'Show the full text').click();
69+
6970
getText(
7071
'If renderWhitespace is set to true, there will be thirteen white spaces in front and after this sent… Show less'
7172
);
7273
cy.get('[ui5-responsive-popover]').should('have.attr', 'open');
74+
cy.findByText('Show less').should('have.attr', 'accessible-name', 'Close the popover').click();
7375
cy.realPress('Escape');
7476
getText(
7577
'If renderWhitespace is set to true, there will be thirteen white spaces in front and after this sent… Show more'
7678
);
79+
cy.findByText('Show more').should('have.attr', 'accessible-name', 'Show the full text');
7780
});
7881

7982
cypressPassThroughTestsFactory(ExpandableText);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ const ExpandableText = forwardRef<HTMLSpanElement, ExpandableTextPropTypes>((pro
120120
accessibleName={
121121
showOverflowInPopover
122122
? collapsed
123-
? i18nBundle.getText(CLOSE_POPOVER)
124-
: i18nBundle.getText(SHOW_FULL_TEXT)
123+
? i18nBundle.getText(SHOW_FULL_TEXT)
124+
: i18nBundle.getText(CLOSE_POPOVER)
125125
: undefined
126126
}
127127
accessibleRole="button"

0 commit comments

Comments
 (0)