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": "Fix for tabindex value change when clicked on icon of the buttons in rich text editor toolbar.",
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
"packageName": "@ni/nimble-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
4 changes: 4 additions & 0 deletions packages/nimble-components/src/rich-text/editor/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ export const styles = css`
place-items: center;
}

vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -78,6 +78,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