Skip to content

Commit 22dfcc2

Browse files
authored
Merge pull request #56 from a-ui/bugfix/several-bug-fixes
Several bug fixes
2 parents 35cbcfe + 0198e62 commit 22dfcc2

28 files changed

Lines changed: 268 additions & 27 deletions

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 7.xx.xx - xxxx-xx-xx
9+
10+
### Added
11+
12+
- Added `required` prop on Upload component
13+
- Added `description` and `state` properties to the `RadioGroup` component
14+
- Added `required` property to the `Checkbox` component
15+
- Added `required` prop to the `Checkbox` component
16+
- Added `required` prop to the `RadioGroup` component
17+
- Added `required` prop to the `Radio` component (not visible in the UI)
18+
- Added `disabled` property to the `Autocomplete` component
19+
20+
### Fixed
21+
22+
- Fixed `Select` component selecting the first option when `value` is empty string; empty string now correctly shows the placeholder.
23+
- Fixed a margin bottom issue with the inline alert title
24+
- Fixed the `aria-describedby` attribute not being linked to `description` text in Datepicker component
25+
- Fixed the required asterisk not being hidden from screen readers
26+
- Fixed not being able to submit the form when the `Autocomplete` component is open
27+
828
## 7.11.1 - 2026-01-07
929

1030
### Fixed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@nrwl/react": "15.8.7",
3838
"@nrwl/vite": "15.8.7",
3939
"@nrwl/workspace": "15.8.7",
40+
"@testing-library/dom": "^10.4.0",
4041
"@testing-library/jest-dom": "^5.16.5",
4142
"@testing-library/react": "^16.3.0",
4243
"@types/jsdom": "^20.0.1",

packages/antwerp-ui/react-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@a-ui/react",
3-
"version": "7.11.0",
3+
"version": "7.11.2",
44
"license": "MIT",
55
"main": "./index.js",
66
"types": "./index.d.ts",

packages/antwerp-ui/react-components/src/lib/atoms/checkbox/Checkbox.spec.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ describe('UI Components - Atoms - Checkbox', () => {
88
const defaultProps: CheckboxProps = {
99
label: 'Checkbox',
1010
id: 'checkbox',
11-
name: 'checkbox'
11+
name: 'checkbox',
12+
required: false
1213
};
1314

1415
it('renders a checkbox with the given label', () => {
@@ -56,4 +57,11 @@ describe('UI Components - Atoms - Checkbox', () => {
5657
fireEvent.click(getByLabelText('Checkbox'));
5758
expect(mockOnChange).toHaveBeenCalled();
5859
});
60+
61+
it('adds a red asterisk to the label when the required prop is true', () => {
62+
const { getByLabelText } = render(<Checkbox {...defaultProps} required />);
63+
const checkbox = getByLabelText(/Checkbox/) as HTMLInputElement;
64+
expect(checkbox).toHaveProperty('required', true);
65+
expect(checkbox.parentElement?.querySelector('.u-text-danger')).toBeInTheDocument();
66+
});
5967
});

packages/antwerp-ui/react-components/src/lib/atoms/checkbox/Checkbox.stories.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export default {
2222
disabled: false,
2323
indeterminate: false,
2424
id: 'checkbox-example',
25-
name: 'agree-checkbox'
25+
name: 'agree-checkbox',
26+
required: false
2627
},
2728
argTypes: {
2829
label: {
@@ -50,6 +51,15 @@ export default {
5051
description:
5152
'Checked state. When this prop is set, the `Checkbox` becomes a controlled component; use it together with `onChange`.'
5253
},
54+
required: {
55+
control: { type: 'boolean' },
56+
table: {
57+
type: { summary: 'boolean' },
58+
defaultValue: { summary: false }
59+
},
60+
description:
61+
'The `required` prop adds a red asterisk to the `Checkbox` label and adds the required attribute to the HTML checkbox field.'
62+
},
5363
disabled: {
5464
control: { type: 'boolean' },
5565
table: {

packages/antwerp-ui/react-components/src/lib/atoms/checkbox/Checkbox.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ChangeEvent } from 'react';
22
import { SCREEN_READER_CLASS } from '../../../constants/settings';
33
import { classNames } from '../../../utils/dom.utils';
4+
import { renderRequiredAsterisk } from '../../../utils/render.utils';
45
import { CheckboxProps } from './Checkbox.types';
56

67
export function Checkbox({
@@ -12,7 +13,8 @@ export function Checkbox({
1213
name,
1314
disabled,
1415
indeterminate,
15-
onChange
16+
onChange,
17+
required = false
1618
}: CheckboxProps) {
1719
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
1820
return onChange && onChange(event);
@@ -40,9 +42,11 @@ export function Checkbox({
4042
ref={setIndeterminate}
4143
disabled={disabled}
4244
onChange={handleChange}
45+
required={required}
4346
/>
4447
<label htmlFor={id}>
4548
<span className={showLabel ? undefined : SCREEN_READER_CLASS}>{label}</span>
49+
{required && renderRequiredAsterisk()}
4650
</label>
4751
</div>
4852
);

packages/antwerp-ui/react-components/src/lib/atoms/checkbox/Checkbox.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export interface CheckboxProps {
1010
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
1111
qa?: string;
1212
showLabel?: boolean;
13+
required?: boolean;
1314
}

packages/antwerp-ui/react-components/src/lib/atoms/input/Input.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface InputProps {
2222
}
2323

2424
export interface TextFieldProps extends InputProps {
25+
ariaDescribedBy?: string;
2526
addOn?: {
2627
type: 'icon' | 'text' | 'spinner';
2728
size?: 'small' | 'medium' | 'large';

packages/antwerp-ui/react-components/src/lib/atoms/input/input.renders.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { State, Theme, THEME_ICON_MAP } from '../../../constants/layout.settings';
22
import { classNames } from '../../../utils/dom.utils';
3+
import { renderRequiredAsterisk } from '../../../utils/render.utils';
34
import { Icon } from '../../base/icon';
45
import { DescriptionProps, LabelProps, CharacterCounterProps } from './Input.types';
56

@@ -12,7 +13,7 @@ export const renderLabel = ({ label, id, required, inline, className = '', noMar
1213
return label ? (
1314
<label className={labelClasses} htmlFor={id}>
1415
{label}
15-
{required && <span className="u-text-danger">*</span>}
16+
{required && renderRequiredAsterisk()}
1617
</label>
1718
) : null;
1819
};

packages/antwerp-ui/react-components/src/lib/atoms/input/text-field/TextField.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const TextField = forwardRef(function TextField(
1111
{
1212
addOn,
1313
autoComplete,
14+
ariaDescribedBy = '',
1415
charCounter,
1516
charCountText,
1617
description,
@@ -48,10 +49,10 @@ export const TextField = forwardRef(function TextField(
4849
const toggleCharCounter = charCounter !== undefined ? charCounter : maxLength ? true : false;
4950
const charCounterText = charCountText ? charCountText : maxLength ? '%count% / %max%' : '%count%';
5051

51-
const describedBy = [
52-
toggleCharCounter ? `${id}--counter` : null,
53-
description ? `${id}--description` : null
54-
].filter(Boolean).join(' ') || undefined;
52+
const describedBy =
53+
[ariaDescribedBy, toggleCharCounter ? `${id}--counter` : null, description ? `${id}--description` : null]
54+
.filter(Boolean)
55+
.join(' ') || undefined;
5556

5657
const classes = classNames({
5758
'a-input': true,

0 commit comments

Comments
 (0)