@instructure/ui-form-field 10.14.1-snapshot-2 → 10.14.1-snapshot-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -2
- package/es/FormField/__new-tests__/FormField.test.js +15 -1
- package/es/FormField/index.js +5 -1
- package/es/FormFieldLayout/styles.js +3 -3
- package/lib/FormField/__new-tests__/FormField.test.js +15 -1
- package/lib/FormField/index.js +5 -1
- package/lib/FormFieldLayout/styles.js +3 -3
- package/package.json +15 -15
- package/src/FormField/__new-tests__/FormField.test.tsx +16 -2
- package/src/FormField/index.tsx +3 -0
- package/src/FormFieldLayout/styles.ts +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/FormField/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.14.1-snapshot-
|
|
6
|
+
## [10.14.1-snapshot-4](https://github.com/instructure/instructure-ui/compare/v10.14.0...v10.14.1-snapshot-4) (2025-03-27)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-form-field:** fix misaligned text when size is exactly at the breakpoint ([142c508](https://github.com/instructure/instructure-ui/commit/142c508992d85ada9c0b70afea50bce0c3bb30d9))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _FormField, _FormField2, _FormField3;
|
|
1
|
+
var _FormField, _FormField2, _FormField3, _FormField4;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -29,6 +29,7 @@ import { vi } from 'vitest';
|
|
|
29
29
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
30
30
|
import '@testing-library/jest-dom';
|
|
31
31
|
import { FormField } from '../index';
|
|
32
|
+
import { userEvent } from '@testing-library/user-event';
|
|
32
33
|
describe('<FormField />', () => {
|
|
33
34
|
let consoleWarningMock;
|
|
34
35
|
let consoleErrorMock;
|
|
@@ -67,4 +68,17 @@ describe('<FormField />', () => {
|
|
|
67
68
|
const axeCheck = await runAxeCheck(container);
|
|
68
69
|
expect(axeCheck).toBe(true);
|
|
69
70
|
});
|
|
71
|
+
it('should focus the control with the supplied id', async () => {
|
|
72
|
+
const user = userEvent.setup();
|
|
73
|
+
render(_FormField4 || (_FormField4 = /*#__PURE__*/React.createElement(FormField, {
|
|
74
|
+
label: "labelText",
|
|
75
|
+
id: "foo"
|
|
76
|
+
}, /*#__PURE__*/React.createElement("input", null), /*#__PURE__*/React.createElement("input", {
|
|
77
|
+
id: "foo"
|
|
78
|
+
}), /*#__PURE__*/React.createElement("input", null))));
|
|
79
|
+
const label = screen.getByText('labelText').closest('label');
|
|
80
|
+
await user.click(label);
|
|
81
|
+
const input = document.getElementById('foo');
|
|
82
|
+
expect(input).toHaveFocus();
|
|
83
|
+
});
|
|
70
84
|
});
|
package/es/FormField/index.js
CHANGED
|
@@ -47,7 +47,11 @@ class FormField extends Component {
|
|
|
47
47
|
return /*#__PURE__*/React.createElement(FormFieldLayout, Object.assign({}, omitProps(this.props, FormField.allowedProps), pickProps(this.props, FormFieldLayout.allowedProps), {
|
|
48
48
|
label: this.props.label,
|
|
49
49
|
vAlign: this.props.vAlign,
|
|
50
|
-
as: "label"
|
|
50
|
+
as: "label"
|
|
51
|
+
// This makes the control in focus when the label is clicked
|
|
52
|
+
// This is needed to prevent the wrong element to be focused, e.g.
|
|
53
|
+
// multi selects Tag-s
|
|
54
|
+
,
|
|
51
55
|
htmlFor: this.props.id,
|
|
52
56
|
elementRef: this.handleRef,
|
|
53
57
|
margin: this.props.margin
|
|
@@ -92,7 +92,7 @@ const generateStyle = (componentTheme, props, styleProps) => {
|
|
|
92
92
|
// when inline add a small padding between the label and the control
|
|
93
93
|
paddingRight: componentTheme.inlinePadding,
|
|
94
94
|
// and use the horizontal alignment prop
|
|
95
|
-
[`@media screen and (
|
|
95
|
+
[`@media screen and (width >= ${componentTheme.stackedOrInlineBreakpoint})`]: {
|
|
96
96
|
textAlign: labelAlign
|
|
97
97
|
}
|
|
98
98
|
})
|
|
@@ -122,7 +122,7 @@ const generateStyle = (componentTheme, props, styleProps) => {
|
|
|
122
122
|
// removes margin in inline layouts
|
|
123
123
|
gridTemplateColumns: gridTemplateColumns,
|
|
124
124
|
gridTemplateAreas: gridTemplateAreas,
|
|
125
|
-
[`@media screen and (
|
|
125
|
+
[`@media screen and (width < ${componentTheme.stackedOrInlineBreakpoint})`]: {
|
|
126
126
|
// for small screens use the stacked layout
|
|
127
127
|
gridTemplateColumns: '100%',
|
|
128
128
|
gridTemplateAreas: generateGridLayout(false, hasNewErrorMsgAndIsGroup, hasVisibleLabel, hasMessages)
|
|
@@ -150,7 +150,7 @@ const generateStyle = (componentTheme, props, styleProps) => {
|
|
|
150
150
|
marginTop: '0.375rem'
|
|
151
151
|
}),
|
|
152
152
|
...(isInlineLayout && inline && {
|
|
153
|
-
[`@media screen and (
|
|
153
|
+
[`@media screen and (width >= ${componentTheme.stackedOrInlineBreakpoint})`]: {
|
|
154
154
|
justifySelf: 'start'
|
|
155
155
|
}
|
|
156
156
|
})
|
|
@@ -7,7 +7,8 @@ var _vitest = require("vitest");
|
|
|
7
7
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
8
8
|
require("@testing-library/jest-dom");
|
|
9
9
|
var _index = require("../index");
|
|
10
|
-
var
|
|
10
|
+
var _userEvent = require("@testing-library/user-event");
|
|
11
|
+
var _FormField, _FormField2, _FormField3, _FormField4;
|
|
11
12
|
/*
|
|
12
13
|
* The MIT License (MIT)
|
|
13
14
|
*
|
|
@@ -69,4 +70,17 @@ describe('<FormField />', () => {
|
|
|
69
70
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
70
71
|
expect(axeCheck).toBe(true);
|
|
71
72
|
});
|
|
73
|
+
it('should focus the control with the supplied id', async () => {
|
|
74
|
+
const user = _userEvent.userEvent.setup();
|
|
75
|
+
(0, _react2.render)(_FormField4 || (_FormField4 = /*#__PURE__*/_react.default.createElement(_index.FormField, {
|
|
76
|
+
label: "labelText",
|
|
77
|
+
id: "foo"
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement("input", null), /*#__PURE__*/_react.default.createElement("input", {
|
|
79
|
+
id: "foo"
|
|
80
|
+
}), /*#__PURE__*/_react.default.createElement("input", null))));
|
|
81
|
+
const label = _react2.screen.getByText('labelText').closest('label');
|
|
82
|
+
await user.click(label);
|
|
83
|
+
const input = document.getElementById('foo');
|
|
84
|
+
expect(input).toHaveFocus();
|
|
85
|
+
});
|
|
72
86
|
});
|
package/lib/FormField/index.js
CHANGED
|
@@ -55,7 +55,11 @@ class FormField extends _react.Component {
|
|
|
55
55
|
return /*#__PURE__*/_react.default.createElement(_FormFieldLayout.FormFieldLayout, Object.assign({}, (0, _omitProps.omitProps)(this.props, FormField.allowedProps), (0, _pickProps.pickProps)(this.props, _FormFieldLayout.FormFieldLayout.allowedProps), {
|
|
56
56
|
label: this.props.label,
|
|
57
57
|
vAlign: this.props.vAlign,
|
|
58
|
-
as: "label"
|
|
58
|
+
as: "label"
|
|
59
|
+
// This makes the control in focus when the label is clicked
|
|
60
|
+
// This is needed to prevent the wrong element to be focused, e.g.
|
|
61
|
+
// multi selects Tag-s
|
|
62
|
+
,
|
|
59
63
|
htmlFor: this.props.id,
|
|
60
64
|
elementRef: this.handleRef,
|
|
61
65
|
margin: this.props.margin
|
|
@@ -98,7 +98,7 @@ const generateStyle = (componentTheme, props, styleProps) => {
|
|
|
98
98
|
// when inline add a small padding between the label and the control
|
|
99
99
|
paddingRight: componentTheme.inlinePadding,
|
|
100
100
|
// and use the horizontal alignment prop
|
|
101
|
-
[`@media screen and (
|
|
101
|
+
[`@media screen and (width >= ${componentTheme.stackedOrInlineBreakpoint})`]: {
|
|
102
102
|
textAlign: labelAlign
|
|
103
103
|
}
|
|
104
104
|
})
|
|
@@ -128,7 +128,7 @@ const generateStyle = (componentTheme, props, styleProps) => {
|
|
|
128
128
|
// removes margin in inline layouts
|
|
129
129
|
gridTemplateColumns: gridTemplateColumns,
|
|
130
130
|
gridTemplateAreas: gridTemplateAreas,
|
|
131
|
-
[`@media screen and (
|
|
131
|
+
[`@media screen and (width < ${componentTheme.stackedOrInlineBreakpoint})`]: {
|
|
132
132
|
// for small screens use the stacked layout
|
|
133
133
|
gridTemplateColumns: '100%',
|
|
134
134
|
gridTemplateAreas: generateGridLayout(false, hasNewErrorMsgAndIsGroup, hasVisibleLabel, hasMessages)
|
|
@@ -156,7 +156,7 @@ const generateStyle = (componentTheme, props, styleProps) => {
|
|
|
156
156
|
marginTop: '0.375rem'
|
|
157
157
|
}),
|
|
158
158
|
...(isInlineLayout && inline && {
|
|
159
|
-
[`@media screen and (
|
|
159
|
+
[`@media screen and (width >= ${componentTheme.stackedOrInlineBreakpoint})`]: {
|
|
160
160
|
justifySelf: 'start'
|
|
161
161
|
}
|
|
162
162
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-form-field",
|
|
3
|
-
"version": "10.14.1-snapshot-
|
|
3
|
+
"version": "10.14.1-snapshot-4",
|
|
4
4
|
"description": "Form layout components.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,26 +23,26 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "10.14.1-snapshot-
|
|
27
|
-
"@instructure/ui-babel-preset": "10.14.1-snapshot-
|
|
28
|
-
"@instructure/ui-test-utils": "10.14.1-snapshot-
|
|
29
|
-
"@instructure/ui-themes": "10.14.1-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "10.14.1-snapshot-4",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.14.1-snapshot-4",
|
|
28
|
+
"@instructure/ui-test-utils": "10.14.1-snapshot-4",
|
|
29
|
+
"@instructure/ui-themes": "10.14.1-snapshot-4",
|
|
30
30
|
"@testing-library/jest-dom": "^6.6.3",
|
|
31
31
|
"@testing-library/react": "^16.0.1",
|
|
32
32
|
"vitest": "^2.1.8"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "^7.26.0",
|
|
36
|
-
"@instructure/console": "10.14.1-snapshot-
|
|
37
|
-
"@instructure/emotion": "10.14.1-snapshot-
|
|
38
|
-
"@instructure/shared-types": "10.14.1-snapshot-
|
|
39
|
-
"@instructure/ui-a11y-content": "10.14.1-snapshot-
|
|
40
|
-
"@instructure/ui-a11y-utils": "10.14.1-snapshot-
|
|
41
|
-
"@instructure/ui-grid": "10.14.1-snapshot-
|
|
42
|
-
"@instructure/ui-icons": "10.14.1-snapshot-
|
|
43
|
-
"@instructure/ui-react-utils": "10.14.1-snapshot-
|
|
44
|
-
"@instructure/ui-utils": "10.14.1-snapshot-
|
|
45
|
-
"@instructure/uid": "10.14.1-snapshot-
|
|
36
|
+
"@instructure/console": "10.14.1-snapshot-4",
|
|
37
|
+
"@instructure/emotion": "10.14.1-snapshot-4",
|
|
38
|
+
"@instructure/shared-types": "10.14.1-snapshot-4",
|
|
39
|
+
"@instructure/ui-a11y-content": "10.14.1-snapshot-4",
|
|
40
|
+
"@instructure/ui-a11y-utils": "10.14.1-snapshot-4",
|
|
41
|
+
"@instructure/ui-grid": "10.14.1-snapshot-4",
|
|
42
|
+
"@instructure/ui-icons": "10.14.1-snapshot-4",
|
|
43
|
+
"@instructure/ui-react-utils": "10.14.1-snapshot-4",
|
|
44
|
+
"@instructure/ui-utils": "10.14.1-snapshot-4",
|
|
45
|
+
"@instructure/uid": "10.14.1-snapshot-4",
|
|
46
46
|
"prop-types": "^15.8.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -29,6 +29,7 @@ import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
|
29
29
|
import '@testing-library/jest-dom'
|
|
30
30
|
|
|
31
31
|
import { FormField } from '../index'
|
|
32
|
+
import { userEvent } from '@testing-library/user-event'
|
|
32
33
|
|
|
33
34
|
describe('<FormField />', () => {
|
|
34
35
|
let consoleWarningMock: ReturnType<typeof vi.spyOn>
|
|
@@ -65,9 +66,22 @@ describe('<FormField />', () => {
|
|
|
65
66
|
|
|
66
67
|
it('should meet a11y standards', async () => {
|
|
67
68
|
const { container } = render(<FormField label="foo" id="bar" />)
|
|
68
|
-
|
|
69
69
|
const axeCheck = await runAxeCheck(container)
|
|
70
|
-
|
|
71
70
|
expect(axeCheck).toBe(true)
|
|
72
71
|
})
|
|
72
|
+
|
|
73
|
+
it('should focus the control with the supplied id', async () => {
|
|
74
|
+
const user = userEvent.setup()
|
|
75
|
+
render(
|
|
76
|
+
<FormField label="labelText" id="foo">
|
|
77
|
+
<input />
|
|
78
|
+
<input id="foo" />
|
|
79
|
+
<input />
|
|
80
|
+
</FormField>
|
|
81
|
+
)
|
|
82
|
+
const label = screen.getByText('labelText').closest('label')!
|
|
83
|
+
await user.click(label)
|
|
84
|
+
const input = document.getElementById('foo')!
|
|
85
|
+
expect(input).toHaveFocus()
|
|
86
|
+
})
|
|
73
87
|
})
|
package/src/FormField/index.tsx
CHANGED
|
@@ -68,6 +68,9 @@ class FormField extends Component<FormFieldProps> {
|
|
|
68
68
|
label={this.props.label}
|
|
69
69
|
vAlign={this.props.vAlign}
|
|
70
70
|
as="label"
|
|
71
|
+
// This makes the control in focus when the label is clicked
|
|
72
|
+
// This is needed to prevent the wrong element to be focused, e.g.
|
|
73
|
+
// multi selects Tag-s
|
|
71
74
|
htmlFor={this.props.id}
|
|
72
75
|
elementRef={this.handleRef}
|
|
73
76
|
margin={this.props.margin}
|
|
@@ -107,7 +107,7 @@ const generateStyle = (
|
|
|
107
107
|
// when inline add a small padding between the label and the control
|
|
108
108
|
paddingRight: componentTheme.inlinePadding,
|
|
109
109
|
// and use the horizontal alignment prop
|
|
110
|
-
[`@media screen and (
|
|
110
|
+
[`@media screen and (width >= ${componentTheme.stackedOrInlineBreakpoint})`]:
|
|
111
111
|
{
|
|
112
112
|
textAlign: labelAlign
|
|
113
113
|
}
|
|
@@ -138,7 +138,7 @@ const generateStyle = (
|
|
|
138
138
|
verticalAlign: 'middle', // removes margin in inline layouts
|
|
139
139
|
gridTemplateColumns: gridTemplateColumns,
|
|
140
140
|
gridTemplateAreas: gridTemplateAreas,
|
|
141
|
-
[`@media screen and (
|
|
141
|
+
[`@media screen and (width < ${componentTheme.stackedOrInlineBreakpoint})`]:
|
|
142
142
|
{
|
|
143
143
|
// for small screens use the stacked layout
|
|
144
144
|
gridTemplateColumns: '100%',
|
|
@@ -171,7 +171,7 @@ const generateStyle = (
|
|
|
171
171
|
...(hasMessages && hasNewErrorMsgAndIsGroup && { marginTop: '0.375rem' }),
|
|
172
172
|
...(isInlineLayout &&
|
|
173
173
|
inline && {
|
|
174
|
-
[`@media screen and (
|
|
174
|
+
[`@media screen and (width >= ${componentTheme.stackedOrInlineBreakpoint})`]:
|
|
175
175
|
{
|
|
176
176
|
justifySelf: 'start'
|
|
177
177
|
}
|