@atlaskit/inline-edit 13.0.6 → 13.0.7
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 +6 -0
- package/dist/cjs/inline-edit.js +70 -70
- package/dist/es2019/inline-edit.js +73 -73
- package/dist/esm/inline-edit.js +70 -70
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/inline-edit
|
|
2
2
|
|
|
3
|
+
## 13.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#65569](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65569) [`bd5d46cc5c52`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bd5d46cc5c52) - Fixes an issue introduced by 12.3.5 that could lead to a page refresh in some cases when event bubbling caused the wrapping form to submit to the current page.
|
|
8
|
+
|
|
3
9
|
## 13.0.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cjs/inline-edit.js
CHANGED
|
@@ -27,7 +27,7 @@ var fieldStyles = (0, _react2.css)({
|
|
|
27
27
|
var analyticsAttributes = {
|
|
28
28
|
componentName: 'inlineEdit',
|
|
29
29
|
packageName: "@atlaskit/inline-edit",
|
|
30
|
-
packageVersion: "13.0.
|
|
30
|
+
packageVersion: "13.0.7"
|
|
31
31
|
};
|
|
32
32
|
var noop = function noop() {};
|
|
33
33
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
@@ -96,7 +96,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
96
96
|
action: 'confirmed',
|
|
97
97
|
analyticsData: analyticsContext
|
|
98
98
|
}, analyticsAttributes));
|
|
99
|
-
var
|
|
99
|
+
var _onCancelClick = (0, _react.useCallback)(function (event) {
|
|
100
100
|
event.preventDefault();
|
|
101
101
|
onCancel();
|
|
102
102
|
}, [onCancel]);
|
|
@@ -110,7 +110,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
110
110
|
}, [doNotFocusOnEditButton]);
|
|
111
111
|
|
|
112
112
|
/** If keepEditViewOpenOnBlur prop is set to false, will call confirmIfUnfocused() which
|
|
113
|
-
* confirms the value, if the focus is not transferred to the action buttons
|
|
113
|
+
* confirms the value, if the focus is not transferred to the action buttons.
|
|
114
114
|
*
|
|
115
115
|
* When you're in `editing` state, the focus will be on the input field. And if you use keyboard
|
|
116
116
|
* to navigate to `submit` button, this function will be invoked. Then function `onEditViewWrapperFocus`
|
|
@@ -120,7 +120,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
120
120
|
* There are two paths here the function can be triggered:
|
|
121
121
|
*
|
|
122
122
|
* - focus on input first, and then use keyboard to `submit`
|
|
123
|
-
* - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save)
|
|
123
|
+
* - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save).
|
|
124
124
|
*/
|
|
125
125
|
var onEditViewWrapperBlur = (0, _react.useCallback)(function (isFieldInvalid, onSubmit, formRef) {
|
|
126
126
|
if (!keepEditViewOpenOnBlur) {
|
|
@@ -131,13 +131,13 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
131
131
|
}
|
|
132
132
|
}, [keepEditViewOpenOnBlur, tryAutoSubmitWhenBlur]);
|
|
133
133
|
|
|
134
|
-
/** Gets called when focus is transferred to the editView, or action buttons
|
|
134
|
+
/** Gets called when focus is transferred to the editView, or action buttons.
|
|
135
135
|
*
|
|
136
136
|
* There are three paths here the function can be called:
|
|
137
137
|
*
|
|
138
138
|
* - when a user click the `editView`
|
|
139
139
|
* - when a user use keyboard to tab into `editView`
|
|
140
|
-
* - when a user use keyboard to tab into `submit` when they were on input field
|
|
140
|
+
* - when a user use keyboard to tab into `submit` when they were on input field.
|
|
141
141
|
*/
|
|
142
142
|
var onEditViewWrapperFocus = (0, _react.useCallback)(function () {
|
|
143
143
|
wasFocusReceivedSinceLastBlurRef.current = true;
|
|
@@ -152,77 +152,77 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
152
152
|
readView: readView
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
155
|
+
return (0, _react2.jsx)(_Form.default, {
|
|
156
|
+
onSubmit: function onSubmit(data) {
|
|
157
|
+
return onConfirm(data.inlineEdit);
|
|
158
|
+
}
|
|
159
|
+
}, function (_ref) {
|
|
160
|
+
var _ref$formProps = _ref.formProps,
|
|
161
|
+
_onKeyDown = _ref$formProps.onKeyDown,
|
|
162
|
+
onSubmit = _ref$formProps.onSubmit,
|
|
163
|
+
formRef = _ref$formProps.ref,
|
|
164
|
+
reset = _ref.reset;
|
|
165
|
+
return (0, _react2.jsx)("form", {
|
|
166
|
+
/**
|
|
167
|
+
* It is not normally acceptable to add key handlers to non-interactive elements
|
|
168
|
+
* as this is an accessibility anti-pattern. However, because this instance is
|
|
169
|
+
* to add support for keyboard functionality instead of creating an inaccessible
|
|
170
|
+
* custom element, we can add role="presentation" so that there is no negative
|
|
171
|
+
* impacts to assistive technologies.
|
|
172
|
+
*/
|
|
173
|
+
role: "presentation",
|
|
174
|
+
onKeyDown: function onKeyDown(e) {
|
|
175
|
+
_onKeyDown(e);
|
|
176
|
+
if (e.key === 'Esc' || e.key === 'Escape') {
|
|
177
|
+
onCancel();
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
onSubmit: onSubmit,
|
|
181
|
+
ref: formRef
|
|
182
|
+
}, shouldBeEditing ? (0, _react2.jsx)(_Field.default, {
|
|
183
|
+
name: "inlineEdit",
|
|
184
|
+
label: label,
|
|
185
|
+
defaultValue: defaultValue,
|
|
186
|
+
validate: validate,
|
|
187
|
+
isRequired: isRequired,
|
|
188
|
+
key: "edit-view" // used for reset to default value
|
|
189
|
+
}, function (_ref2) {
|
|
190
|
+
var fieldProps = _ref2.fieldProps,
|
|
191
|
+
error = _ref2.error;
|
|
192
|
+
return (0, _react2.jsx)("div", {
|
|
193
|
+
css: fieldStyles,
|
|
194
|
+
onBlur: function onBlur() {
|
|
195
|
+
onEditViewWrapperBlur(fieldProps.isInvalid, onSubmit, formRef);
|
|
196
|
+
},
|
|
197
|
+
onFocus: onEditViewWrapperFocus
|
|
198
|
+
}, editView(_objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
199
|
+
errorMessage: error
|
|
200
|
+
}), editViewRef), !hideActionButtons ? (0, _react2.jsx)(_buttons.default, {
|
|
201
|
+
cancelButtonLabel: cancelButtonLabel,
|
|
202
|
+
confirmButtonLabel: confirmButtonLabel,
|
|
203
|
+
onMouseDown: function onMouseDown() {
|
|
204
|
+
/** Prevents focus on edit button only if mouse is used to click button, but not when keyboard is used */
|
|
205
|
+
doNotFocusOnEditButton();
|
|
179
206
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}, function (_ref2) {
|
|
190
|
-
var fieldProps = _ref2.fieldProps,
|
|
191
|
-
error = _ref2.error;
|
|
192
|
-
return (0, _react2.jsx)("div", {
|
|
193
|
-
css: fieldStyles,
|
|
194
|
-
onBlur: function onBlur() {
|
|
195
|
-
onEditViewWrapperBlur(fieldProps.isInvalid, onSubmit, formRef);
|
|
196
|
-
},
|
|
197
|
-
onFocus: onEditViewWrapperFocus
|
|
198
|
-
}, editView(_objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
199
|
-
errorMessage: error
|
|
200
|
-
}), editViewRef), !hideActionButtons ? (0, _react2.jsx)(_buttons.default, {
|
|
201
|
-
cancelButtonLabel: cancelButtonLabel,
|
|
202
|
-
confirmButtonLabel: confirmButtonLabel,
|
|
203
|
-
onMouseDown: function onMouseDown() {
|
|
204
|
-
/** Prevents focus on edit button only if mouse is used to click button, but not when keyboard is used */
|
|
205
|
-
doNotFocusOnEditButton();
|
|
206
|
-
},
|
|
207
|
-
onCancelClick: onCancelClick
|
|
208
|
-
}) : /** This is to allow Ctrl + Enter to submit without action buttons */
|
|
209
|
-
(0, _react2.jsx)("button", {
|
|
210
|
-
hidden: true,
|
|
211
|
-
type: "submit",
|
|
212
|
-
"aria-label": "Submit"
|
|
213
|
-
}));
|
|
207
|
+
onCancelClick: function onCancelClick(e) {
|
|
208
|
+
reset();
|
|
209
|
+
_onCancelClick(e);
|
|
210
|
+
}
|
|
211
|
+
}) : /** This is to allow Ctrl + Enter to submit without action buttons */
|
|
212
|
+
(0, _react2.jsx)("button", {
|
|
213
|
+
hidden: true,
|
|
214
|
+
type: "submit",
|
|
215
|
+
"aria-label": "Submit"
|
|
214
216
|
}));
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
return (/** Form, Field are used here only for the label and spacing */
|
|
218
|
-
(0, _react2.jsx)("form", null, (0, _react2.jsx)(_Field.default, {
|
|
217
|
+
}) : /** Field is used here only for the label and spacing */
|
|
218
|
+
(0, _react2.jsx)(_Field.default, {
|
|
219
219
|
name: "inlineEdit",
|
|
220
220
|
label: label,
|
|
221
221
|
defaultValue: "",
|
|
222
222
|
isRequired: isRequired,
|
|
223
223
|
key: "read-view" // used for reset to default value
|
|
224
|
-
}, renderReadView))
|
|
225
|
-
);
|
|
224
|
+
}, renderReadView));
|
|
225
|
+
});
|
|
226
226
|
};
|
|
227
227
|
var InlineEdit = function InlineEdit(props) {
|
|
228
228
|
return (0, _react2.jsx)(InnerInlineEdit, props);
|
|
@@ -14,7 +14,7 @@ const fieldStyles = css({
|
|
|
14
14
|
const analyticsAttributes = {
|
|
15
15
|
componentName: 'inlineEdit',
|
|
16
16
|
packageName: "@atlaskit/inline-edit",
|
|
17
|
-
packageVersion: "13.0.
|
|
17
|
+
packageVersion: "13.0.7"
|
|
18
18
|
};
|
|
19
19
|
const noop = () => {};
|
|
20
20
|
const InnerInlineEdit = props => {
|
|
@@ -88,7 +88,7 @@ const InnerInlineEdit = props => {
|
|
|
88
88
|
}, [doNotFocusOnEditButton]);
|
|
89
89
|
|
|
90
90
|
/** If keepEditViewOpenOnBlur prop is set to false, will call confirmIfUnfocused() which
|
|
91
|
-
* confirms the value, if the focus is not transferred to the action buttons
|
|
91
|
+
* confirms the value, if the focus is not transferred to the action buttons.
|
|
92
92
|
*
|
|
93
93
|
* When you're in `editing` state, the focus will be on the input field. And if you use keyboard
|
|
94
94
|
* to navigate to `submit` button, this function will be invoked. Then function `onEditViewWrapperFocus`
|
|
@@ -98,7 +98,7 @@ const InnerInlineEdit = props => {
|
|
|
98
98
|
* There are two paths here the function can be triggered:
|
|
99
99
|
*
|
|
100
100
|
* - focus on input first, and then use keyboard to `submit`
|
|
101
|
-
* - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save)
|
|
101
|
+
* - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save).
|
|
102
102
|
*/
|
|
103
103
|
const onEditViewWrapperBlur = useCallback((isFieldInvalid, onSubmit, formRef) => {
|
|
104
104
|
if (!keepEditViewOpenOnBlur) {
|
|
@@ -107,13 +107,13 @@ const InnerInlineEdit = props => {
|
|
|
107
107
|
}
|
|
108
108
|
}, [keepEditViewOpenOnBlur, tryAutoSubmitWhenBlur]);
|
|
109
109
|
|
|
110
|
-
/** Gets called when focus is transferred to the editView, or action buttons
|
|
110
|
+
/** Gets called when focus is transferred to the editView, or action buttons.
|
|
111
111
|
*
|
|
112
112
|
* There are three paths here the function can be called:
|
|
113
113
|
*
|
|
114
114
|
* - when a user click the `editView`
|
|
115
115
|
* - when a user use keyboard to tab into `editView`
|
|
116
|
-
* - when a user use keyboard to tab into `submit` when they were on input field
|
|
116
|
+
* - when a user use keyboard to tab into `submit` when they were on input field.
|
|
117
117
|
*/
|
|
118
118
|
const onEditViewWrapperFocus = useCallback(() => {
|
|
119
119
|
wasFocusReceivedSinceLastBlurRef.current = true;
|
|
@@ -128,75 +128,75 @@ const InnerInlineEdit = props => {
|
|
|
128
128
|
readView: readView
|
|
129
129
|
});
|
|
130
130
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
onSubmit,
|
|
138
|
-
ref: formRef
|
|
139
|
-
}
|
|
140
|
-
}) => jsx("form", {
|
|
141
|
-
/**
|
|
142
|
-
* It is not normally acceptable to add key handlers to non-interactive elements
|
|
143
|
-
* as this is an accessibility anti-pattern. However, because this instance is
|
|
144
|
-
* to add support for keyboard functionality instead of creating an inaccessible
|
|
145
|
-
* custom element, we can add role="presentation" so that there is no negative
|
|
146
|
-
* impacts to assistive technologies.
|
|
147
|
-
*/
|
|
148
|
-
role: "presentation",
|
|
149
|
-
onKeyDown: e => {
|
|
150
|
-
onKeyDown(e);
|
|
151
|
-
if (e.key === 'Esc' || e.key === 'Escape') {
|
|
152
|
-
onCancel();
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
onSubmit: onSubmit,
|
|
131
|
+
return jsx(Form, {
|
|
132
|
+
onSubmit: data => onConfirm(data.inlineEdit)
|
|
133
|
+
}, ({
|
|
134
|
+
formProps: {
|
|
135
|
+
onKeyDown,
|
|
136
|
+
onSubmit,
|
|
156
137
|
ref: formRef
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
138
|
+
},
|
|
139
|
+
reset
|
|
140
|
+
}) => jsx("form", {
|
|
141
|
+
/**
|
|
142
|
+
* It is not normally acceptable to add key handlers to non-interactive elements
|
|
143
|
+
* as this is an accessibility anti-pattern. However, because this instance is
|
|
144
|
+
* to add support for keyboard functionality instead of creating an inaccessible
|
|
145
|
+
* custom element, we can add role="presentation" so that there is no negative
|
|
146
|
+
* impacts to assistive technologies.
|
|
147
|
+
*/
|
|
148
|
+
role: "presentation",
|
|
149
|
+
onKeyDown: e => {
|
|
150
|
+
onKeyDown(e);
|
|
151
|
+
if (e.key === 'Esc' || e.key === 'Escape') {
|
|
152
|
+
onCancel();
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
onSubmit: onSubmit,
|
|
156
|
+
ref: formRef
|
|
157
|
+
}, shouldBeEditing ? jsx(Field, {
|
|
158
|
+
name: "inlineEdit",
|
|
159
|
+
label: label,
|
|
160
|
+
defaultValue: defaultValue,
|
|
161
|
+
validate: validate,
|
|
162
|
+
isRequired: isRequired,
|
|
163
|
+
key: "edit-view" // used for reset to default value
|
|
164
|
+
}, ({
|
|
165
|
+
fieldProps,
|
|
166
|
+
error
|
|
167
|
+
}) => jsx("div", {
|
|
168
|
+
css: fieldStyles,
|
|
169
|
+
onBlur: () => {
|
|
170
|
+
onEditViewWrapperBlur(fieldProps.isInvalid, onSubmit, formRef);
|
|
171
|
+
},
|
|
172
|
+
onFocus: onEditViewWrapperFocus
|
|
173
|
+
}, editView({
|
|
174
|
+
...fieldProps,
|
|
175
|
+
errorMessage: error
|
|
176
|
+
}, editViewRef), !hideActionButtons ? jsx(Buttons, {
|
|
177
|
+
cancelButtonLabel: cancelButtonLabel,
|
|
178
|
+
confirmButtonLabel: confirmButtonLabel,
|
|
179
|
+
onMouseDown: () => {
|
|
180
|
+
/** Prevents focus on edit button only if mouse is used to click button, but not when keyboard is used */
|
|
181
|
+
doNotFocusOnEditButton();
|
|
182
|
+
},
|
|
183
|
+
onCancelClick: e => {
|
|
184
|
+
reset();
|
|
185
|
+
onCancelClick(e);
|
|
186
|
+
}
|
|
187
|
+
}) : /** This is to allow Ctrl + Enter to submit without action buttons */
|
|
188
|
+
jsx("button", {
|
|
189
|
+
hidden: true,
|
|
190
|
+
type: "submit",
|
|
191
|
+
"aria-label": "Submit"
|
|
192
|
+
}))) : /** Field is used here only for the label and spacing */
|
|
193
|
+
jsx(Field, {
|
|
194
|
+
name: "inlineEdit",
|
|
195
|
+
label: label,
|
|
196
|
+
defaultValue: "",
|
|
197
|
+
isRequired: isRequired,
|
|
198
|
+
key: "read-view" // used for reset to default value
|
|
199
|
+
}, renderReadView)));
|
|
200
200
|
};
|
|
201
201
|
const InlineEdit = props => {
|
|
202
202
|
return jsx(InnerInlineEdit, props);
|
package/dist/esm/inline-edit.js
CHANGED
|
@@ -18,7 +18,7 @@ var fieldStyles = css({
|
|
|
18
18
|
var analyticsAttributes = {
|
|
19
19
|
componentName: 'inlineEdit',
|
|
20
20
|
packageName: "@atlaskit/inline-edit",
|
|
21
|
-
packageVersion: "13.0.
|
|
21
|
+
packageVersion: "13.0.7"
|
|
22
22
|
};
|
|
23
23
|
var noop = function noop() {};
|
|
24
24
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
@@ -87,7 +87,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
87
87
|
action: 'confirmed',
|
|
88
88
|
analyticsData: analyticsContext
|
|
89
89
|
}, analyticsAttributes));
|
|
90
|
-
var
|
|
90
|
+
var _onCancelClick = useCallback(function (event) {
|
|
91
91
|
event.preventDefault();
|
|
92
92
|
onCancel();
|
|
93
93
|
}, [onCancel]);
|
|
@@ -101,7 +101,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
101
101
|
}, [doNotFocusOnEditButton]);
|
|
102
102
|
|
|
103
103
|
/** If keepEditViewOpenOnBlur prop is set to false, will call confirmIfUnfocused() which
|
|
104
|
-
* confirms the value, if the focus is not transferred to the action buttons
|
|
104
|
+
* confirms the value, if the focus is not transferred to the action buttons.
|
|
105
105
|
*
|
|
106
106
|
* When you're in `editing` state, the focus will be on the input field. And if you use keyboard
|
|
107
107
|
* to navigate to `submit` button, this function will be invoked. Then function `onEditViewWrapperFocus`
|
|
@@ -111,7 +111,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
111
111
|
* There are two paths here the function can be triggered:
|
|
112
112
|
*
|
|
113
113
|
* - focus on input first, and then use keyboard to `submit`
|
|
114
|
-
* - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save)
|
|
114
|
+
* - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save).
|
|
115
115
|
*/
|
|
116
116
|
var onEditViewWrapperBlur = useCallback(function (isFieldInvalid, onSubmit, formRef) {
|
|
117
117
|
if (!keepEditViewOpenOnBlur) {
|
|
@@ -122,13 +122,13 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
122
122
|
}
|
|
123
123
|
}, [keepEditViewOpenOnBlur, tryAutoSubmitWhenBlur]);
|
|
124
124
|
|
|
125
|
-
/** Gets called when focus is transferred to the editView, or action buttons
|
|
125
|
+
/** Gets called when focus is transferred to the editView, or action buttons.
|
|
126
126
|
*
|
|
127
127
|
* There are three paths here the function can be called:
|
|
128
128
|
*
|
|
129
129
|
* - when a user click the `editView`
|
|
130
130
|
* - when a user use keyboard to tab into `editView`
|
|
131
|
-
* - when a user use keyboard to tab into `submit` when they were on input field
|
|
131
|
+
* - when a user use keyboard to tab into `submit` when they were on input field.
|
|
132
132
|
*/
|
|
133
133
|
var onEditViewWrapperFocus = useCallback(function () {
|
|
134
134
|
wasFocusReceivedSinceLastBlurRef.current = true;
|
|
@@ -143,77 +143,77 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
143
143
|
readView: readView
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
146
|
+
return jsx(Form, {
|
|
147
|
+
onSubmit: function onSubmit(data) {
|
|
148
|
+
return onConfirm(data.inlineEdit);
|
|
149
|
+
}
|
|
150
|
+
}, function (_ref) {
|
|
151
|
+
var _ref$formProps = _ref.formProps,
|
|
152
|
+
_onKeyDown = _ref$formProps.onKeyDown,
|
|
153
|
+
onSubmit = _ref$formProps.onSubmit,
|
|
154
|
+
formRef = _ref$formProps.ref,
|
|
155
|
+
reset = _ref.reset;
|
|
156
|
+
return jsx("form", {
|
|
157
|
+
/**
|
|
158
|
+
* It is not normally acceptable to add key handlers to non-interactive elements
|
|
159
|
+
* as this is an accessibility anti-pattern. However, because this instance is
|
|
160
|
+
* to add support for keyboard functionality instead of creating an inaccessible
|
|
161
|
+
* custom element, we can add role="presentation" so that there is no negative
|
|
162
|
+
* impacts to assistive technologies.
|
|
163
|
+
*/
|
|
164
|
+
role: "presentation",
|
|
165
|
+
onKeyDown: function onKeyDown(e) {
|
|
166
|
+
_onKeyDown(e);
|
|
167
|
+
if (e.key === 'Esc' || e.key === 'Escape') {
|
|
168
|
+
onCancel();
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
onSubmit: onSubmit,
|
|
172
|
+
ref: formRef
|
|
173
|
+
}, shouldBeEditing ? jsx(Field, {
|
|
174
|
+
name: "inlineEdit",
|
|
175
|
+
label: label,
|
|
176
|
+
defaultValue: defaultValue,
|
|
177
|
+
validate: validate,
|
|
178
|
+
isRequired: isRequired,
|
|
179
|
+
key: "edit-view" // used for reset to default value
|
|
180
|
+
}, function (_ref2) {
|
|
181
|
+
var fieldProps = _ref2.fieldProps,
|
|
182
|
+
error = _ref2.error;
|
|
183
|
+
return jsx("div", {
|
|
184
|
+
css: fieldStyles,
|
|
185
|
+
onBlur: function onBlur() {
|
|
186
|
+
onEditViewWrapperBlur(fieldProps.isInvalid, onSubmit, formRef);
|
|
187
|
+
},
|
|
188
|
+
onFocus: onEditViewWrapperFocus
|
|
189
|
+
}, editView(_objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
190
|
+
errorMessage: error
|
|
191
|
+
}), editViewRef), !hideActionButtons ? jsx(Buttons, {
|
|
192
|
+
cancelButtonLabel: cancelButtonLabel,
|
|
193
|
+
confirmButtonLabel: confirmButtonLabel,
|
|
194
|
+
onMouseDown: function onMouseDown() {
|
|
195
|
+
/** Prevents focus on edit button only if mouse is used to click button, but not when keyboard is used */
|
|
196
|
+
doNotFocusOnEditButton();
|
|
170
197
|
},
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}, function (_ref2) {
|
|
181
|
-
var fieldProps = _ref2.fieldProps,
|
|
182
|
-
error = _ref2.error;
|
|
183
|
-
return jsx("div", {
|
|
184
|
-
css: fieldStyles,
|
|
185
|
-
onBlur: function onBlur() {
|
|
186
|
-
onEditViewWrapperBlur(fieldProps.isInvalid, onSubmit, formRef);
|
|
187
|
-
},
|
|
188
|
-
onFocus: onEditViewWrapperFocus
|
|
189
|
-
}, editView(_objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
190
|
-
errorMessage: error
|
|
191
|
-
}), editViewRef), !hideActionButtons ? jsx(Buttons, {
|
|
192
|
-
cancelButtonLabel: cancelButtonLabel,
|
|
193
|
-
confirmButtonLabel: confirmButtonLabel,
|
|
194
|
-
onMouseDown: function onMouseDown() {
|
|
195
|
-
/** Prevents focus on edit button only if mouse is used to click button, but not when keyboard is used */
|
|
196
|
-
doNotFocusOnEditButton();
|
|
197
|
-
},
|
|
198
|
-
onCancelClick: onCancelClick
|
|
199
|
-
}) : /** This is to allow Ctrl + Enter to submit without action buttons */
|
|
200
|
-
jsx("button", {
|
|
201
|
-
hidden: true,
|
|
202
|
-
type: "submit",
|
|
203
|
-
"aria-label": "Submit"
|
|
204
|
-
}));
|
|
198
|
+
onCancelClick: function onCancelClick(e) {
|
|
199
|
+
reset();
|
|
200
|
+
_onCancelClick(e);
|
|
201
|
+
}
|
|
202
|
+
}) : /** This is to allow Ctrl + Enter to submit without action buttons */
|
|
203
|
+
jsx("button", {
|
|
204
|
+
hidden: true,
|
|
205
|
+
type: "submit",
|
|
206
|
+
"aria-label": "Submit"
|
|
205
207
|
}));
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
return (/** Form, Field are used here only for the label and spacing */
|
|
209
|
-
jsx("form", null, jsx(Field, {
|
|
208
|
+
}) : /** Field is used here only for the label and spacing */
|
|
209
|
+
jsx(Field, {
|
|
210
210
|
name: "inlineEdit",
|
|
211
211
|
label: label,
|
|
212
212
|
defaultValue: "",
|
|
213
213
|
isRequired: isRequired,
|
|
214
214
|
key: "read-view" // used for reset to default value
|
|
215
|
-
}, renderReadView))
|
|
216
|
-
);
|
|
215
|
+
}, renderReadView));
|
|
216
|
+
});
|
|
217
217
|
};
|
|
218
218
|
var InlineEdit = function InlineEdit(props) {
|
|
219
219
|
return jsx(InnerInlineEdit, props);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/inline-edit",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.7",
|
|
4
4
|
"description": "An inline edit displays a custom input component that switches between reading and editing on the same page.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@atlaskit/analytics-next": "^9.
|
|
39
|
-
"@atlaskit/button": "^17.
|
|
38
|
+
"@atlaskit/analytics-next": "^9.2.0",
|
|
39
|
+
"@atlaskit/button": "^17.3.0",
|
|
40
40
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
41
41
|
"@atlaskit/form": "^9.0.3",
|
|
42
42
|
"@atlaskit/icon": "^22.0.0",
|
|
43
43
|
"@atlaskit/inline-dialog": "^14.0.0",
|
|
44
44
|
"@atlaskit/textfield": "^6.0.0",
|
|
45
45
|
"@atlaskit/theme": "^12.6.0",
|
|
46
|
-
"@atlaskit/tokens": "^1.
|
|
46
|
+
"@atlaskit/tokens": "^1.36.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|
|
48
48
|
"@emotion/react": "^11.7.1"
|
|
49
49
|
},
|