From a4dba4da1bb3fa129085da84b64a1201c45b64e5 Mon Sep 17 00:00:00 2001 From: anastasiia_glushkova Date: Tue, 17 Dec 2024 13:37:32 +0100 Subject: [PATCH] feat(core): make shadow interaction components are recognized as focusable --- core/src/components/cat-avatar/cat-avatar.tsx | 9 +++++++-- core/src/components/cat-button/cat-button.tsx | 5 ++++- core/src/components/cat-checkbox/cat-checkbox.tsx | 5 ++++- core/src/components/cat-date-inline/cat-date-inline.tsx | 5 ++++- core/src/components/cat-date/cat-date.tsx | 5 ++++- core/src/components/cat-input/cat-input.tsx | 5 ++++- core/src/components/cat-pagination/cat-pagination.tsx | 8 ++++++-- core/src/components/cat-radio/cat-radio.tsx | 5 ++++- core/src/components/cat-select/cat-select.tsx | 5 ++++- core/src/components/cat-tabs/cat-tabs.tsx | 5 ++++- core/src/components/cat-tag/cat-tag.tsx | 5 ++++- core/src/components/cat-textarea/cat-textarea.tsx | 5 ++++- core/src/components/cat-time/cat-time.tsx | 5 ++++- core/src/components/cat-toggle/cat-toggle.tsx | 5 ++++- 14 files changed, 61 insertions(+), 16 deletions(-) diff --git a/core/src/components/cat-avatar/cat-avatar.tsx b/core/src/components/cat-avatar/cat-avatar.tsx index 9b287ec6d..30276832e 100644 --- a/core/src/components/cat-avatar/cat-avatar.tsx +++ b/core/src/components/cat-avatar/cat-avatar.tsx @@ -1,4 +1,4 @@ -import { Component, h, Prop, State, Watch } from '@stencil/core'; +import { Component, Element, h, Prop, State, Watch } from '@stencil/core'; import loadImg from '../../utils/load-img'; /** @@ -7,11 +7,15 @@ import loadImg from '../../utils/load-img'; @Component({ tag: 'cat-avatar', styleUrl: 'cat-avatar.scss', - shadow: true + shadow: { + delegatesFocus: true, + } }) export class CatAvatar { @State() backgroundImage?: string; + @Element() hostElement!: HTMLElement; + /** * The size of the avatar. */ @@ -70,6 +74,7 @@ export class CatAvatar { render() { if (this.url) { + this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0; return ( {this.content} diff --git a/core/src/components/cat-button/cat-button.tsx b/core/src/components/cat-button/cat-button.tsx index 13fc5057e..c60e7e197 100644 --- a/core/src/components/cat-button/cat-button.tsx +++ b/core/src/components/cat-button/cat-button.tsx @@ -15,7 +15,9 @@ import { findClosest } from '../../utils/find-closest'; @Component({ tag: 'cat-button', styleUrl: 'cat-button.scss', - shadow: true + shadow: { + delegatesFocus: true, + } }) export class CatButton { private button!: HTMLButtonElement | HTMLAnchorElement; @@ -236,6 +238,7 @@ export class CatButton { } render() { + this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0; if (this.url) { return ( diff --git a/core/src/components/cat-checkbox/cat-checkbox.tsx b/core/src/components/cat-checkbox/cat-checkbox.tsx index fbed13f3c..91fcafeae 100644 --- a/core/src/components/cat-checkbox/cat-checkbox.tsx +++ b/core/src/components/cat-checkbox/cat-checkbox.tsx @@ -16,7 +16,9 @@ let nextUniqueId = 0; @Component({ tag: 'cat-checkbox', styleUrls: ['cat-checkbox.scss'], - shadow: true + shadow: { + delegatesFocus: true, + } }) export class CatCheckbox { private readonly _id = `cat-checkbox-${nextUniqueId++}`; @@ -162,6 +164,7 @@ export class CatCheckbox { } render() { + this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0; return (