@atlaskit/link-picker 1.7.1 → 1.8.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
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/link-picker
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`89fffde2a59`](https://bitbucket.org/atlassian/atlassian-frontend/commits/89fffde2a59) - Wrap link picker in native form element
8
+
3
9
  ## 1.7.1
4
10
 
5
11
  ### Patch Changes
@@ -247,10 +247,13 @@ function LinkPicker(_ref) {
247
247
  if (selectedItem) {
248
248
  var _url = selectedItem.url,
249
249
  name = selectedItem.name;
250
+ dispatchEvent(new Event('submit'));
250
251
  handleInsert(_url, name, 'typeAhead');
251
252
  }
252
253
  }, [handleInsert, items]);
253
- var handleSubmit = (0, _react.useCallback)(function () {
254
+ var handleSubmit = (0, _react.useCallback)(function (event) {
255
+ event.preventDefault();
256
+
254
257
  if (isSelectedItem && selectedItem) {
255
258
  return handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
256
259
  }
@@ -283,9 +286,10 @@ function LinkPicker(_ref) {
283
286
  size: "medium",
284
287
  label: ''
285
288
  }));
286
- return (0, _react2.jsx)("div", {
289
+ return (0, _react2.jsx)("form", {
287
290
  "data-testid": testIds.linkPicker,
288
- css: _styled.rootContainerStyles
291
+ css: _styled.rootContainerStyles,
292
+ onSubmit: handleSubmit
289
293
  }, screenReaderText && (0, _react2.jsx)(_announcer.default, {
290
294
  ariaLive: "assertive",
291
295
  text: screenReaderText,
@@ -311,7 +315,6 @@ function LinkPicker(_ref) {
311
315
  "aria-describedby": screenReaderDescriptionId,
312
316
  error: invalidUrl ? intl.formatMessage(_messages.messages.linkInvalid) : null,
313
317
  onClear: handleClear,
314
- onSubmit: handleSubmit,
315
318
  onKeyDown: handleKeyDown,
316
319
  onChange: handleChangeUrl
317
320
  }), (0, _react2.jsx)(_textInput.default, {
@@ -324,7 +327,6 @@ function LinkPicker(_ref) {
324
327
  clearLabel: intl.formatMessage(_messages.messages.clearText),
325
328
  "aria-label": intl.formatMessage(_messages.messages.linkAriaLabel),
326
329
  onClear: handleClear,
327
- onSubmit: handleSubmit,
328
330
  onKeyDown: handleKeyDown,
329
331
  onChange: handleChangeText
330
332
  }), queryState && (0, _react2.jsx)(_react.Fragment, null, tabs.length > 0 && (0, _react2.jsx)("div", {
@@ -398,7 +400,6 @@ function LinkPicker(_ref) {
398
400
  }, intl.formatMessage(_messages.messages.cancelButton)), (0, _react2.jsx)(_button.default, {
399
401
  type: "submit",
400
402
  appearance: "primary",
401
- onClick: handleSubmit,
402
403
  testId: testIds.insertButton
403
404
  }, intl.formatMessage(insertButtonMsg)))));
404
405
  }
@@ -29,13 +29,12 @@ var _styled = require("./styled");
29
29
 
30
30
  var _ = require("../");
31
31
 
32
- var _excluded = ["name", "label", "autoFocus", "onSubmit", "onRedo", "onUndo", "onChange", "onKeyDown", "onClear", "clearLabel", "error"];
32
+ var _excluded = ["name", "label", "autoFocus", "onRedo", "onUndo", "onChange", "onKeyDown", "onClear", "clearLabel", "error"];
33
33
 
34
34
  var PanelTextInput = function PanelTextInput(props) {
35
35
  var name = props.name,
36
36
  label = props.label,
37
37
  autoFocus = props.autoFocus,
38
- onSubmit = props.onSubmit,
39
38
  onRedo = props.onRedo,
40
39
  onUndo = props.onUndo,
41
40
  onChange = props.onChange,
@@ -61,13 +60,7 @@ var PanelTextInput = function PanelTextInput(props) {
61
60
  onChange(e.currentTarget.value);
62
61
  }, [onChange]);
63
62
  var handleKeydown = (0, _react.useCallback)(function (e) {
64
- var value = e.currentTarget.value;
65
-
66
- if (e.keyCode === 13 && onSubmit) {
67
- e.preventDefault(); // Prevent from submitting if an editor is inside a form.
68
-
69
- onSubmit(value);
70
- } else if (typeof onUndo === 'function' && (0, _utils.isUndoEvent)(e)) {
63
+ if (typeof onUndo === 'function' && (0, _utils.isUndoEvent)(e)) {
71
64
  e.preventDefault();
72
65
  onUndo();
73
66
  } else if (typeof onRedo === 'function' && (0, _utils.isRedoEvent)(e)) {
@@ -78,7 +71,7 @@ var PanelTextInput = function PanelTextInput(props) {
78
71
  if (onKeyDown) {
79
72
  onKeyDown(e);
80
73
  }
81
- }, [onSubmit, onUndo, onRedo, onKeyDown]);
74
+ }, [onUndo, onRedo, onKeyDown]);
82
75
  var handleClear = (0, _react.useCallback)(function () {
83
76
  if (inputRef.current && onClear) {
84
77
  inputRef.current.focus();
@@ -88,6 +81,7 @@ var PanelTextInput = function PanelTextInput(props) {
88
81
  var clearText = restProps.value !== '' && (0, _react2.jsx)(_tooltip.default, {
89
82
  content: clearLabel
90
83
  }, (0, _react2.jsx)("button", {
84
+ type: "button",
91
85
  css: _styled.clearTextButtonStyles,
92
86
  onClick: handleClear,
93
87
  "data-testid": _.testIds.clearUrlButton
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "sideEffects": false
5
5
  }
@@ -200,10 +200,13 @@ function LinkPicker({
200
200
  url,
201
201
  name
202
202
  } = selectedItem;
203
+ dispatchEvent(new Event('submit'));
203
204
  handleInsert(url, name, 'typeAhead');
204
205
  }
205
206
  }, [handleInsert, items]);
206
- const handleSubmit = useCallback(() => {
207
+ const handleSubmit = useCallback(event => {
208
+ event.preventDefault();
209
+
207
210
  if (isSelectedItem && selectedItem) {
208
211
  return handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
209
212
  }
@@ -236,9 +239,10 @@ function LinkPicker({
236
239
  size: "medium",
237
240
  label: ''
238
241
  }));
239
- return jsx("div", {
242
+ return jsx("form", {
240
243
  "data-testid": testIds.linkPicker,
241
- css: rootContainerStyles
244
+ css: rootContainerStyles,
245
+ onSubmit: handleSubmit
242
246
  }, screenReaderText && jsx(Announcer, {
243
247
  ariaLive: "assertive",
244
248
  text: screenReaderText,
@@ -264,7 +268,6 @@ function LinkPicker({
264
268
  "aria-describedby": screenReaderDescriptionId,
265
269
  error: invalidUrl ? intl.formatMessage(messages.linkInvalid) : null,
266
270
  onClear: handleClear,
267
- onSubmit: handleSubmit,
268
271
  onKeyDown: handleKeyDown,
269
272
  onChange: handleChangeUrl
270
273
  }), jsx(PanelTextInput, {
@@ -277,7 +280,6 @@ function LinkPicker({
277
280
  clearLabel: intl.formatMessage(messages.clearText),
278
281
  "aria-label": intl.formatMessage(messages.linkAriaLabel),
279
282
  onClear: handleClear,
280
- onSubmit: handleSubmit,
281
283
  onKeyDown: handleKeyDown,
282
284
  onChange: handleChangeText
283
285
  }), queryState && jsx(Fragment, null, tabs.length > 0 && jsx("div", {
@@ -345,7 +347,6 @@ function LinkPicker({
345
347
  }, intl.formatMessage(messages.cancelButton)), jsx(Button, {
346
348
  type: "submit",
347
349
  appearance: "primary",
348
- onClick: handleSubmit,
349
350
  testId: testIds.insertButton
350
351
  }, intl.formatMessage(insertButtonMsg)))));
351
352
  }
@@ -16,7 +16,6 @@ const PanelTextInput = props => {
16
16
  name,
17
17
  label,
18
18
  autoFocus,
19
- onSubmit,
20
19
  onRedo,
21
20
  onUndo,
22
21
  onChange,
@@ -43,13 +42,7 @@ const PanelTextInput = props => {
43
42
  onChange(e.currentTarget.value);
44
43
  }, [onChange]);
45
44
  const handleKeydown = useCallback(e => {
46
- const value = e.currentTarget.value;
47
-
48
- if (e.keyCode === 13 && onSubmit) {
49
- e.preventDefault(); // Prevent from submitting if an editor is inside a form.
50
-
51
- onSubmit(value);
52
- } else if (typeof onUndo === 'function' && isUndoEvent(e)) {
45
+ if (typeof onUndo === 'function' && isUndoEvent(e)) {
53
46
  e.preventDefault();
54
47
  onUndo();
55
48
  } else if (typeof onRedo === 'function' && isRedoEvent(e)) {
@@ -60,7 +53,7 @@ const PanelTextInput = props => {
60
53
  if (onKeyDown) {
61
54
  onKeyDown(e);
62
55
  }
63
- }, [onSubmit, onUndo, onRedo, onKeyDown]);
56
+ }, [onUndo, onRedo, onKeyDown]);
64
57
  const handleClear = useCallback(() => {
65
58
  if (inputRef.current && onClear) {
66
59
  inputRef.current.focus();
@@ -70,6 +63,7 @@ const PanelTextInput = props => {
70
63
  const clearText = restProps.value !== '' && jsx(Tooltip, {
71
64
  content: clearLabel
72
65
  }, jsx("button", {
66
+ type: "button",
73
67
  css: clearTextButtonStyles,
74
68
  onClick: handleClear,
75
69
  "data-testid": testIds.clearUrlButton
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "sideEffects": false
5
5
  }
@@ -205,10 +205,13 @@ function LinkPicker(_ref) {
205
205
  if (selectedItem) {
206
206
  var _url = selectedItem.url,
207
207
  name = selectedItem.name;
208
+ dispatchEvent(new Event('submit'));
208
209
  handleInsert(_url, name, 'typeAhead');
209
210
  }
210
211
  }, [handleInsert, items]);
211
- var handleSubmit = useCallback(function () {
212
+ var handleSubmit = useCallback(function (event) {
213
+ event.preventDefault();
214
+
212
215
  if (isSelectedItem && selectedItem) {
213
216
  return handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
214
217
  }
@@ -241,9 +244,10 @@ function LinkPicker(_ref) {
241
244
  size: "medium",
242
245
  label: ''
243
246
  }));
244
- return jsx("div", {
247
+ return jsx("form", {
245
248
  "data-testid": testIds.linkPicker,
246
- css: rootContainerStyles
249
+ css: rootContainerStyles,
250
+ onSubmit: handleSubmit
247
251
  }, screenReaderText && jsx(Announcer, {
248
252
  ariaLive: "assertive",
249
253
  text: screenReaderText,
@@ -269,7 +273,6 @@ function LinkPicker(_ref) {
269
273
  "aria-describedby": screenReaderDescriptionId,
270
274
  error: invalidUrl ? intl.formatMessage(messages.linkInvalid) : null,
271
275
  onClear: handleClear,
272
- onSubmit: handleSubmit,
273
276
  onKeyDown: handleKeyDown,
274
277
  onChange: handleChangeUrl
275
278
  }), jsx(PanelTextInput, {
@@ -282,7 +285,6 @@ function LinkPicker(_ref) {
282
285
  clearLabel: intl.formatMessage(messages.clearText),
283
286
  "aria-label": intl.formatMessage(messages.linkAriaLabel),
284
287
  onClear: handleClear,
285
- onSubmit: handleSubmit,
286
288
  onKeyDown: handleKeyDown,
287
289
  onChange: handleChangeText
288
290
  }), queryState && jsx(Fragment, null, tabs.length > 0 && jsx("div", {
@@ -356,7 +358,6 @@ function LinkPicker(_ref) {
356
358
  }, intl.formatMessage(messages.cancelButton)), jsx(Button, {
357
359
  type: "submit",
358
360
  appearance: "primary",
359
- onClick: handleSubmit,
360
361
  testId: testIds.insertButton
361
362
  }, intl.formatMessage(insertButtonMsg)))));
362
363
  }
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["name", "label", "autoFocus", "onSubmit", "onRedo", "onUndo", "onChange", "onKeyDown", "onClear", "clearLabel", "error"];
3
+ var _excluded = ["name", "label", "autoFocus", "onRedo", "onUndo", "onChange", "onKeyDown", "onClear", "clearLabel", "error"];
4
4
 
5
5
  /** @jsx jsx */
6
6
  import { useCallback, useRef, Fragment } from 'react';
@@ -17,7 +17,6 @@ var PanelTextInput = function PanelTextInput(props) {
17
17
  var name = props.name,
18
18
  label = props.label,
19
19
  autoFocus = props.autoFocus,
20
- onSubmit = props.onSubmit,
21
20
  onRedo = props.onRedo,
22
21
  onUndo = props.onUndo,
23
22
  onChange = props.onChange,
@@ -44,13 +43,7 @@ var PanelTextInput = function PanelTextInput(props) {
44
43
  onChange(e.currentTarget.value);
45
44
  }, [onChange]);
46
45
  var handleKeydown = useCallback(function (e) {
47
- var value = e.currentTarget.value;
48
-
49
- if (e.keyCode === 13 && onSubmit) {
50
- e.preventDefault(); // Prevent from submitting if an editor is inside a form.
51
-
52
- onSubmit(value);
53
- } else if (typeof onUndo === 'function' && isUndoEvent(e)) {
46
+ if (typeof onUndo === 'function' && isUndoEvent(e)) {
54
47
  e.preventDefault();
55
48
  onUndo();
56
49
  } else if (typeof onRedo === 'function' && isRedoEvent(e)) {
@@ -61,7 +54,7 @@ var PanelTextInput = function PanelTextInput(props) {
61
54
  if (onKeyDown) {
62
55
  onKeyDown(e);
63
56
  }
64
- }, [onSubmit, onUndo, onRedo, onKeyDown]);
57
+ }, [onUndo, onRedo, onKeyDown]);
65
58
  var handleClear = useCallback(function () {
66
59
  if (inputRef.current && onClear) {
67
60
  inputRef.current.focus();
@@ -71,6 +64,7 @@ var PanelTextInput = function PanelTextInput(props) {
71
64
  var clearText = restProps.value !== '' && jsx(Tooltip, {
72
65
  content: clearLabel
73
66
  }, jsx("button", {
67
+ type: "button",
74
68
  css: clearTextButtonStyles,
75
69
  onClick: handleClear,
76
70
  "data-testid": testIds.clearUrlButton
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "sideEffects": false
5
5
  }
@@ -6,7 +6,6 @@ export interface Props extends Omit<TextFieldProps, 'value' | 'onChange' | 'auto
6
6
  autoFocus?: boolean;
7
7
  value: string;
8
8
  onChange: (value: string) => void;
9
- onSubmit?: (value: string) => void;
10
9
  onUndo?: Function;
11
10
  onRedo?: Function;
12
11
  onClear?: Function;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "description": "Standalone link picker",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
@@ -63,8 +63,8 @@
63
63
  "@atlaskit/visual-regression": "*",
64
64
  "@atlaskit/webdriver-runner": "*",
65
65
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
66
- "@atlassian/link-picker-atlassian-plugin": "^17.0.0",
67
- "@atlassian/link-picker-plugins": "^4.0.0",
66
+ "@atlassian/link-picker-atlassian-plugin": "^18.0.0",
67
+ "@atlassian/link-picker-plugins": "^5.0.0",
68
68
  "@atlassian/recent-work-client": "^1.5.0",
69
69
  "@atlassian/search-provider": "^2.3.0",
70
70
  "@testing-library/dom": "^7.7.3",