Skip to content

Commit 327eebe

Browse files
refactor: removed aria attributes which have a 1:1 mapping (#4476)
* refactor: removed aria attributes which has a 1:1 mapping * chore: update test * chore: update test * auto update snapshots (#4479) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * auto update snapshots (#4485) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent c571741 commit 327eebe

File tree

26 files changed

+79
-120
lines changed

26 files changed

+79
-120
lines changed
3.98 KB
Loading
-336 Bytes
Loading
-3.83 KB
Loading
2.3 KB
Loading

docs/migration/v2.x.x-to-v3.0.0.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,45 @@ Furthermore, we added a trailing icon to the `db-button`/`DBButton` component.
99
You can still use `db-icon`/`icon` in most elements/components, which results in showing the default icon.
1010
Most of the time this will be the leading icon, but in some cases it might be the trailing icon, depending on the component.
1111

12+
## Aria properties in components
13+
14+
### `db-button`/`DBButton`
15+
16+
- **Removed**: `describedbyid` property, just use `aria-describedby`
17+
- **Removed**: `ariaexpanded` property, just use `aria-expanded`
18+
- **Removed**: `ariapressed` property, just use `aria-pressed`
19+
- **Removed**: `label` property, just use `aria-label`
20+
21+
### `db-link`/`DBLink`
22+
23+
- **Removed**: `selected` property, just use `aria-selected`
24+
- **Removed**: `current` property, just use `aria-current`
25+
- **Removed**: `label` property, just use `aria-label`
26+
27+
### `db-navigation`/`DBNavigation`
28+
29+
- **Removed**: `labelledBy` property, just use `aria-labelledby`
30+
31+
### `db-radio`/`DBRadio`
32+
33+
- **Removed**: `describedbyid` property, just use `aria-describedby`
34+
35+
### `db-switch`/`DBSwitch`
36+
37+
- **Removed**: `describedbyid` property, just use `aria-describedby`
38+
39+
### `db-tab-item`/`DBTabItem`
40+
41+
- **Removed**: `controls` property, just use `aria-controls`
42+
43+
### `db-tab-panel`/`DBTabPanel`
44+
45+
- **Removed**: `labelledBy` property, just use `aria-labelledby`
46+
47+
### `db-tag`/`DBTag`
48+
49+
- **Removed**: `disabled` property, use `disabled` on child component like `button` or `a` tag
50+
1251
## Automate migration via CLI
1352

1453
We provide a CLI tool to auto migrate your source code. Use this command in your repository:

packages/components/src/components/button/button.lite.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default function DBButton(props: DBButtonProps) {
2525
class={cls('db-button', props.className)}
2626
type={props.type || 'button'}
2727
disabled={getBoolean(props.disabled, 'disabled')}
28-
aria-label={props.label}
2928
data-icon={props.iconLeading ?? props.icon}
3029
data-hide-icon={getHideProp(
3130
props.showIconLeading ?? props.showIcon
@@ -39,10 +38,7 @@ export default function DBButton(props: DBButtonProps) {
3938
data-no-text={getBooleanAsString(props.noText)}
4039
name={props.name}
4140
form={props.form}
42-
value={props.value}
43-
aria-describedby={props.describedbyid}
44-
aria-expanded={props.ariaexpanded}
45-
aria-pressed={props.ariapressed}>
41+
value={props.value}>
4642
<Show when={props.text} else={props.children}>
4743
{props.text}
4844
</Show>

packages/components/src/components/button/model.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ export const ButtonStateList = ['loading'] as const;
2929
export type ButtonStateType = (typeof ButtonStateList)[number];
3030

3131
export type DBButtonDefaultProps = {
32-
/**
33-
* If the button controls a grouping of other elements, the ariaexpanded state [indicates whether the controlled grouping is currently expanded or collapsed](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded).
34-
*/
35-
ariaexpanded?: boolean;
36-
37-
/**
38-
* Defines the button as a toggle button. The value of [ariapressed describes the state of the button](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-pressed).
39-
*/
40-
ariapressed?: boolean;
41-
4232
/**
4333
* The disabled attribute can be set to [keep a user from clicking on the button](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#disabled).
4434
*/
@@ -49,11 +39,6 @@ export type DBButtonDefaultProps = {
4939
*/
5040
form?: string;
5141

52-
/**
53-
* The label represents the [aria-label attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label) value of the button
54-
*/
55-
label?: string;
56-
5742
/**
5843
* The name attribute specifies a [name attributes value](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#name) for the button.
5944
*/

packages/components/src/components/drawer/model.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ export type DBDrawerDefaultProps = {
5858
* Set the variant modal|inside. Defaults to modal.
5959
*/
6060
variant?: DrawerVariantType;
61-
/**
62-
* The position attribute changes the css-position (fixed or absolute) of the drawer.
63-
*
64-
* - `fixed` (default): Renders with `showModal()`, creating a true modal with a focus trap.
65-
* - `absolute`: Renders with `show()`, acting as a simple overlay **without** a focus trap.
66-
*/
61+
/**
62+
* The position attribute changes the css-position (fixed or absolute) of the drawer.
63+
*
64+
* - `fixed` (default): Renders with `showModal()`, creating a true modal with a focus trap.
65+
* - `absolute`: Renders with `show()`, acting as a simple overlay **without** a focus trap.
66+
*/
6767
position?: DrawerPositionType;
6868
};
6969

packages/components/src/components/link/link.lite.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ export default function DBLink(props: DBLinkProps) {
2626
hrefLang={props.hreflang}
2727
aria-disabled={getBooleanAsString(props.disabled)}
2828
tabIndex={props.disabled ? -1 : 0}
29-
aria-selected={getBooleanAsString(props.selected)}
30-
aria-label={props.label}
31-
aria-current={props.current}
3229
data-size={props.size}
3330
data-hide-icon-trailing={getHideProp(props.showIcon ?? true)}
3431
data-variant={props.variant}

packages/components/src/components/navigation/model.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import {
2-
AriaLabelledByProps,
3-
GlobalProps,
4-
GlobalState
5-
} from '../../shared/model';
1+
import { GlobalProps, GlobalState } from '../../shared/model';
62

73
export type DBNavigationDefaultProps = {};
84

9-
export type DBNavigationProps = DBNavigationDefaultProps &
10-
GlobalProps &
11-
AriaLabelledByProps;
5+
export type DBNavigationProps = DBNavigationDefaultProps & GlobalProps;
126

137
export type DBNavigationDefaultState = {};
148

0 commit comments

Comments
 (0)