@instructure/ui-text-input 8.20.1-snapshot.5 → 8.21.0

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,6 +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
+ # [8.21.0](https://github.com/instructure/instructure-ui/compare/v8.20.0...v8.21.0) (2022-03-30)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **ui-text-input:** fix Event handling for `TextInput`, so that the focus ring will appear as intended when used as `Popover` trigger ([002505b](https://github.com/instructure/instructure-ui/commit/002505b762a235d29c27eb3fc8b69bcaff7482c2))
11
+
6
12
  # [8.20.0](https://github.com/instructure/instructure-ui/compare/v8.19.0...v8.20.0) (2022-03-22)
7
13
 
8
14
  **Note:** Version bump only for package @instructure/ui-text-input
@@ -30,7 +30,7 @@ var _dec, _dec2, _dec3, _class, _class2, _temp;
30
30
  /** @jsx jsx */
31
31
  import React, { Component } from 'react';
32
32
  import { callRenderProp, getInteraction, passthroughProps, withDeterministicId } from '@instructure/ui-react-utils';
33
- import { isActiveElement } from '@instructure/ui-dom-utils';
33
+ import { isActiveElement, addEventListener } from '@instructure/ui-dom-utils';
34
34
  import { FormField } from '@instructure/ui-form-field';
35
35
  import { testable } from '@instructure/ui-testable';
36
36
  import { withStyle, jsx } from '@instructure/emotion';
@@ -52,6 +52,7 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
52
52
  this._input = null;
53
53
  this._defaultId = void 0;
54
54
  this._messagesId = void 0;
55
+ this._focusListener = null;
55
56
 
56
57
  this.handleRef = el => {
57
58
  const elementRef = this.props.elementRef;
@@ -116,6 +117,16 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
116
117
  var _this$props$makeStyle, _this$props;
117
118
 
118
119
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
120
+
121
+ if (this._input) {
122
+ this._focusListener = addEventListener(this._input, 'focus', this.handleFocus);
123
+ }
124
+ }
125
+
126
+ componentWillUnmount() {
127
+ if (this._focusListener) {
128
+ this._focusListener.remove();
129
+ }
119
130
  }
120
131
 
121
132
  componentDidUpdate() {
@@ -202,8 +213,7 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
202
213
  "aria-describedby": descriptionIds !== '' ? descriptionIds : void 0,
203
214
  size: htmlSize,
204
215
  onChange: this.handleChange,
205
- onBlur: this.handleBlur,
206
- onFocus: this.handleFocus
216
+ onBlur: this.handleBlur
207
217
  }));
208
218
  }
209
219
 
@@ -23,6 +23,8 @@ var _withDeterministicId = require("@instructure/ui-react-utils/lib/Deterministi
23
23
 
24
24
  var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
25
25
 
26
+ var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
27
+
26
28
  var _FormField = require("@instructure/ui-form-field/lib/FormField");
27
29
 
28
30
  var _testable = require("@instructure/ui-testable/lib/testable.js");
@@ -53,6 +55,7 @@ let TextInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
53
55
  this._input = null;
54
56
  this._defaultId = void 0;
55
57
  this._messagesId = void 0;
58
+ this._focusListener = null;
56
59
 
57
60
  this.handleRef = el => {
58
61
  const elementRef = this.props.elementRef;
@@ -117,6 +120,16 @@ let TextInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
117
120
  var _this$props$makeStyle, _this$props;
118
121
 
119
122
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
123
+
124
+ if (this._input) {
125
+ this._focusListener = (0, _addEventListener.addEventListener)(this._input, 'focus', this.handleFocus);
126
+ }
127
+ }
128
+
129
+ componentWillUnmount() {
130
+ if (this._focusListener) {
131
+ this._focusListener.remove();
132
+ }
120
133
  }
121
134
 
122
135
  componentDidUpdate() {
@@ -202,8 +215,7 @@ let TextInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
202
215
  "aria-describedby": descriptionIds !== '' ? descriptionIds : void 0,
203
216
  size: htmlSize,
204
217
  onChange: this.handleChange,
205
- onBlur: this.handleBlur,
206
- onFocus: this.handleFocus
218
+ onBlur: this.handleBlur
207
219
  }));
208
220
  }
209
221
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-text-input",
3
- "version": "8.20.1-snapshot.5+b20e944b1",
3
+ "version": "8.21.0",
4
4
  "description": "A styled HTML text input component.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,23 +23,23 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "8.20.1-snapshot.5+b20e944b1",
27
- "@instructure/ui-badge": "8.20.1-snapshot.5+b20e944b1",
28
- "@instructure/ui-color-utils": "8.20.1-snapshot.5+b20e944b1",
29
- "@instructure/ui-test-utils": "8.20.1-snapshot.5+b20e944b1",
30
- "@instructure/ui-themes": "8.20.1-snapshot.5+b20e944b1"
26
+ "@instructure/ui-babel-preset": "8.21.0",
27
+ "@instructure/ui-badge": "8.21.0",
28
+ "@instructure/ui-color-utils": "8.21.0",
29
+ "@instructure/ui-test-utils": "8.21.0",
30
+ "@instructure/ui-themes": "8.21.0"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.13.10",
34
- "@instructure/emotion": "8.20.1-snapshot.5+b20e944b1",
35
- "@instructure/shared-types": "8.20.1-snapshot.5+b20e944b1",
36
- "@instructure/ui-dom-utils": "8.20.1-snapshot.5+b20e944b1",
37
- "@instructure/ui-form-field": "8.20.1-snapshot.5+b20e944b1",
38
- "@instructure/ui-icons": "8.20.1-snapshot.5+b20e944b1",
39
- "@instructure/ui-prop-types": "8.20.1-snapshot.5+b20e944b1",
40
- "@instructure/ui-react-utils": "8.20.1-snapshot.5+b20e944b1",
41
- "@instructure/ui-tag": "8.20.1-snapshot.5+b20e944b1",
42
- "@instructure/ui-testable": "8.20.1-snapshot.5+b20e944b1",
34
+ "@instructure/emotion": "8.21.0",
35
+ "@instructure/shared-types": "8.21.0",
36
+ "@instructure/ui-dom-utils": "8.21.0",
37
+ "@instructure/ui-form-field": "8.21.0",
38
+ "@instructure/ui-icons": "8.21.0",
39
+ "@instructure/ui-prop-types": "8.21.0",
40
+ "@instructure/ui-react-utils": "8.21.0",
41
+ "@instructure/ui-tag": "8.21.0",
42
+ "@instructure/ui-testable": "8.21.0",
43
43
  "prop-types": "^15"
44
44
  },
45
45
  "peerDependencies": {
@@ -48,6 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "sideEffects": false,
52
- "gitHead": "b20e944b13616f430d7b27eb61ccdb3eb3c87fcf"
51
+ "sideEffects": false
53
52
  }
@@ -31,7 +31,7 @@ import {
31
31
  passthroughProps,
32
32
  withDeterministicId
33
33
  } from '@instructure/ui-react-utils'
34
- import { isActiveElement } from '@instructure/ui-dom-utils'
34
+ import { isActiveElement, addEventListener } from '@instructure/ui-dom-utils'
35
35
  import { FormField } from '@instructure/ui-form-field'
36
36
  import { testable } from '@instructure/ui-testable'
37
37
  import { withStyle, jsx } from '@instructure/emotion'
@@ -85,6 +85,7 @@ class TextInput extends Component<TextInputProps, TextInputState> {
85
85
  private _input: HTMLInputElement | null = null
86
86
  private _defaultId: string
87
87
  private _messagesId: string
88
+ private _focusListener: { remove(): void } | null = null
88
89
 
89
90
  handleRef = (el: Element | null) => {
90
91
  const { elementRef } = this.props
@@ -97,6 +98,19 @@ class TextInput extends Component<TextInputProps, TextInputState> {
97
98
  }
98
99
  componentDidMount() {
99
100
  this.props.makeStyles?.(this.makeStyleProps())
101
+ if (this._input) {
102
+ this._focusListener = addEventListener(
103
+ this._input,
104
+ 'focus',
105
+ this.handleFocus
106
+ )
107
+ }
108
+ }
109
+
110
+ componentWillUnmount() {
111
+ if (this._focusListener) {
112
+ this._focusListener.remove()
113
+ }
100
114
  }
101
115
 
102
116
  componentDidUpdate() {
@@ -225,7 +239,6 @@ class TextInput extends Component<TextInputProps, TextInputState> {
225
239
  size={htmlSize}
226
240
  onChange={this.handleChange}
227
241
  onBlur={this.handleBlur}
228
- onFocus={this.handleFocus}
229
242
  />
230
243
  )
231
244
  }