Fix accessibility and consistency of MessageComposerButtons (#7679)

This commit is contained in:
Michael Telatynski 2022-01-31 16:05:05 +00:00 committed by GitHub
parent a17d585a12
commit 991257cbc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 94 additions and 75 deletions

View file

@ -77,6 +77,7 @@ describe("MessageComposerButtons", () => {
narrowMode={true}
showLocationButton={true}
showStickersButton={true}
toggleButtonMenu={() => {}}
/>,
);
@ -159,28 +160,28 @@ function createRoomState(room: Room): IRoomState {
function buttonLabels(buttons: ReactWrapper): any[] {
// Note: Depends on the fact that the mini buttons use aria-label
// and the labels under More options use label
// and the labels under More options use textContent
const mainButtons = (
buttons
.find('div')
.map((button: ReactWrapper) => button.prop("aria-label"))
.find('div.mx_MessageComposer_button[aria-label]')
.map((button: ReactWrapper) => button.prop("aria-label") as string)
.filter(x => x)
);
let extraButtons = (
const extraButtons = (
buttons
.find('div')
.map((button: ReactWrapper) => button.prop("label"))
.find('.mx_MessageComposer_Menu div.mx_AccessibleButton[role="menuitem"]')
.map((button: ReactWrapper) => button.text())
.filter(x => x)
);
if (extraButtons.length === 0) {
extraButtons = [];
} else {
extraButtons = [extraButtons];
const list: any[] = [
...mainButtons,
];
if (extraButtons.length > 0) {
list.push(extraButtons);
}
return [
...mainButtons,
...extraButtons,
];
return list;
}