Skip to content

Commit 814fa76

Browse files
FieldTimeSelect Field Label aria fix (#1567)
1 parent 38b9c9c commit 814fa76

File tree

12 files changed

+65
-20
lines changed

12 files changed

+65
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ 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-
## UNRELEASED
8+
## [UNRELEASED]
99

1010
### Changed
1111

1212
- InputDateRange allows you to specify a single day range by clicking on one of the date range endpoints
1313

14+
### Fixed
15+
16+
- Aria accessibily fixes for `FieldTimeSelect` label
17+
1418
## [0.9.18]
1519

1620
### Added
12 Bytes
Loading
-2 Bytes
Loading
-1 Bytes
Loading
2.96 KB
Loading
2.91 KB
Loading
7.56 KB
Loading
3.08 KB
Loading

storybook/src/Forms/TimeSelect.stories.tsx renamed to packages/components/src/Form/Fields/FieldTimeSelect/FieldTimeSelect.story.tsx

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,50 @@
2424
2525
*/
2626
import React, { useState } from 'react'
27-
import { ButtonToggle, FieldTimeSelect, Fieldset } from '@looker/components'
27+
import { Story } from '@storybook/react/types-6-0'
28+
import { ButtonToggle } from '../../../Button'
29+
import { Fieldset } from '../../Fieldset'
30+
import { FieldTimeSelect, FieldTimeSelectProps } from './'
2831

2932
export default {
30-
title: 'Forms/TimeSelect',
33+
component: FieldTimeSelect,
34+
title: 'FieldTimeSelect',
3135
}
3236

33-
export const Basic = () => <FieldTimeSelect interval={10} label="Label" />
34-
35-
export const Disabled = () => (
36-
<FieldTimeSelect disabled label="Label" interval={10} />
37+
const Template: Story<FieldTimeSelectProps> = (args) => (
38+
<FieldTimeSelect {...args} />
3739
)
3840

39-
export const Required = () => (
40-
<FieldTimeSelect interval={10} required label="Label" />
41-
)
41+
export const Basic = Template.bind({})
42+
Basic.args = {
43+
defaultValue: '14:30',
44+
interval: 10,
45+
label: 'Select Time',
46+
}
4247

43-
export const Error = () => (
44-
<FieldTimeSelect
45-
interval={10}
46-
description="this is the description is a very long one"
47-
detail="detail"
48-
label="Label"
49-
validationMessage={{ message: 'validation Message', type: 'error' }}
50-
/>
51-
)
48+
export const Disabled = Template.bind({})
49+
Disabled.args = {
50+
disabled: true,
51+
interval: 10,
52+
label: 'Select Time',
53+
}
54+
55+
export const Required = Template.bind({})
56+
Required.args = {
57+
interval: 10,
58+
label: 'Select Time',
59+
required: true,
60+
}
61+
62+
export const Error = Template.bind({})
63+
Error.args = {
64+
description: 'this is the description is a very long one',
65+
detail: 'detail',
66+
interval: 10,
67+
label: 'Select Time',
68+
required: true,
69+
validationMessage: { message: 'validation Message', type: 'error' },
70+
}
5271

5372
export const Controlled = () => {
5473
const [controlledTime, setControlledTime] = useState<any>('09:00')
@@ -85,3 +104,7 @@ export const Controlled = () => {
85104
</>
86105
)
87106
}
107+
108+
Controlled.parameters = {
109+
storyshots: { disable: true },
110+
}

packages/components/src/Form/Fields/FieldTimeSelect/FieldTimeSelect.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ import React from 'react'
2828
import { mountWithTheme, renderWithTheme } from '@looker/components-test-utils'
2929
import { FieldTimeSelect } from './FieldTimeSelect'
3030

31+
test('FieldTimeSelect should associate label and input field', () => {
32+
const { getByLabelText } = renderWithTheme(
33+
<FieldTimeSelect
34+
label="Field Time Label"
35+
id="field-time-select"
36+
interval={10}
37+
/>
38+
)
39+
expect(getByLabelText('Field Time Label').tagName).toEqual('INPUT')
40+
})
41+
3142
test('FieldTimeSelect should accept required attributes', () => {
3243
const { getByText } = renderWithTheme(
3344
<FieldTimeSelect

0 commit comments

Comments
 (0)