@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 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-2](https://github.com/instructure/instructure-ui/compare/v10.14.0...v10.14.1-snapshot-2) (2025-03-18)
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
- **Note:** Version bump only for package @instructure/ui-form-field
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
  });
@@ -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 (min-width: ${componentTheme.stackedOrInlineBreakpoint})`]: {
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 (max-width: ${componentTheme.stackedOrInlineBreakpoint})`]: {
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 (min-width: ${componentTheme.stackedOrInlineBreakpoint})`]: {
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 _FormField, _FormField2, _FormField3;
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
  });
@@ -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 (min-width: ${componentTheme.stackedOrInlineBreakpoint})`]: {
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 (max-width: ${componentTheme.stackedOrInlineBreakpoint})`]: {
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 (min-width: ${componentTheme.stackedOrInlineBreakpoint})`]: {
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-2",
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-2",
27
- "@instructure/ui-babel-preset": "10.14.1-snapshot-2",
28
- "@instructure/ui-test-utils": "10.14.1-snapshot-2",
29
- "@instructure/ui-themes": "10.14.1-snapshot-2",
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-2",
37
- "@instructure/emotion": "10.14.1-snapshot-2",
38
- "@instructure/shared-types": "10.14.1-snapshot-2",
39
- "@instructure/ui-a11y-content": "10.14.1-snapshot-2",
40
- "@instructure/ui-a11y-utils": "10.14.1-snapshot-2",
41
- "@instructure/ui-grid": "10.14.1-snapshot-2",
42
- "@instructure/ui-icons": "10.14.1-snapshot-2",
43
- "@instructure/ui-react-utils": "10.14.1-snapshot-2",
44
- "@instructure/ui-utils": "10.14.1-snapshot-2",
45
- "@instructure/uid": "10.14.1-snapshot-2",
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
  })
@@ -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 (min-width: ${componentTheme.stackedOrInlineBreakpoint})`]:
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 (max-width: ${componentTheme.stackedOrInlineBreakpoint})`]:
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 (min-width: ${componentTheme.stackedOrInlineBreakpoint})`]:
174
+ [`@media screen and (width >= ${componentTheme.stackedOrInlineBreakpoint})`]:
175
175
  {
176
176
  justifySelf: 'start'
177
177
  }