Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich text editor | Fix for updating "tabindex" of button in toolbar when clicking on the icon #1503

Merged
merged 11 commits into from
Sep 13, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Update tabindex when clicking icon of a button in rich text editor toolbar.",
"packageName": "@ni/nimble-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
10 changes: 10 additions & 0 deletions packages/nimble-components/src/rich-text/editor/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ export const styles = css`
gap: ${standardPadding};
place-items: center;
}
${
/**
* Restricting the pointer-events for the slot="start" where the icon is rendered.
* This can be removed after the below issue is fixed.
* https://github.com/ni/nimble/issues/1422
*/ ''
}
nimble-toggle-button::part(start) {
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
pointer-events: none;
}

:host([error-visible]) .error-icon {
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export class RichTextEditorPageObject {
await waitForUpdatesAsync();
}

public async clickFooterIconSlot(button: ToolbarButton): Promise<void> {
const icon = this.getIconSlot(button);
icon!.click();
await waitForUpdatesAsync();
}

public getButtonCheckedState(button: ToolbarButton): boolean {
const toggleButton = this.getFormattingButton(button);
return toggleButton!.checked;
Expand Down Expand Up @@ -217,4 +223,11 @@ export class RichTextEditorPageObject {
);
return buttons[button];
}

private getIconSlot(
button: ToolbarButton
): HTMLSpanElement | null | undefined {
const toggleButton = this.getFormattingButton(button);
return toggleButton?.shadowRoot?.querySelector('.start');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,28 @@ describe('RichTextEditor', () => {
}
});

describe('clicking icon slots should update the tab index of the button', () => {
const focused: string[] = [];
const disabled: string[] = [];

for (const value of formattingButtons) {
const specType = getSpecTypeByNamedList(value, focused, disabled);
specType(
`"${value.name}" button icon click check`,
// eslint-disable-next-line @typescript-eslint/no-loop-func
async () => {
await pageObject.clickFooterIconSlot(
value.toolbarButtonIndex
);

expect(
pageObject.getButtonTabIndex(value.toolbarButtonIndex)
).toBe(0);
}
);
}
});

describe('space key press should update the checked state of the buttons', () => {
const focused: string[] = [];
const disabled: string[] = [];
Expand Down
Loading