@patternfly/react-core 5.0.0-alpha.55 → 5.0.0-alpha.56

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/esm/components/Dropdown/Dropdown.d.ts.map +1 -1
  3. package/dist/esm/components/Dropdown/Dropdown.js +1 -1
  4. package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
  5. package/dist/esm/components/Menu/MenuItem.d.ts +3 -1
  6. package/dist/esm/components/Menu/MenuItem.d.ts.map +1 -1
  7. package/dist/esm/components/Menu/MenuItem.js +7 -6
  8. package/dist/esm/components/Menu/MenuItem.js.map +1 -1
  9. package/dist/esm/components/Wizard/WizardNavItem.d.ts.map +1 -1
  10. package/dist/esm/components/Wizard/WizardNavItem.js +2 -1
  11. package/dist/esm/components/Wizard/WizardNavItem.js.map +1 -1
  12. package/dist/js/components/Dropdown/Dropdown.d.ts.map +1 -1
  13. package/dist/js/components/Dropdown/Dropdown.js +1 -1
  14. package/dist/js/components/Dropdown/Dropdown.js.map +1 -1
  15. package/dist/js/components/Menu/MenuItem.d.ts +3 -1
  16. package/dist/js/components/Menu/MenuItem.d.ts.map +1 -1
  17. package/dist/js/components/Menu/MenuItem.js +7 -6
  18. package/dist/js/components/Menu/MenuItem.js.map +1 -1
  19. package/dist/js/components/Wizard/WizardNavItem.d.ts.map +1 -1
  20. package/dist/js/components/Wizard/WizardNavItem.js +2 -1
  21. package/dist/js/components/Wizard/WizardNavItem.js.map +1 -1
  22. package/dist/umd/react-core.min.js +1 -1
  23. package/package.json +2 -2
  24. package/src/components/Dropdown/Dropdown.tsx +3 -1
  25. package/src/components/Menu/MenuItem.tsx +10 -7
  26. package/src/components/Menu/examples/Menu.md +1 -1
  27. package/src/components/Wizard/WizardNavItem.tsx +2 -1
  28. package/src/components/Wizard/__tests__/Generated/__snapshots__/WizardNavItem.test.tsx.snap +1 -0
  29. package/src/components/Wizard/__tests__/__snapshots__/Wizard.test.tsx.snap +13 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "5.0.0-alpha.55",
3
+ "version": "5.0.0-alpha.56",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -70,5 +70,5 @@
70
70
  "react": "^17 || ^18",
71
71
  "react-dom": "^17 || ^18"
72
72
  },
73
- "gitHead": "21de59660d27027e268526e8fe05cc359104a32e"
73
+ "gitHead": "f5265aae0915a98e62352c4cc3d66d5082832528"
74
74
  }
@@ -74,7 +74,9 @@ const DropdownBase: React.FunctionComponent<DropdownProps> = ({
74
74
  // toggle was clicked open via keyboard, focus on first menu item
75
75
  if (isOpen && toggleRef.current?.contains(event.target as Node) && event.detail === 0) {
76
76
  setTimeout(() => {
77
- const firstElement = menuRef?.current?.querySelector('li button:not(:disabled),li input:not(:disabled)');
77
+ const firstElement = menuRef?.current?.querySelector(
78
+ 'li button:not(:disabled),li input:not(:disabled),li a:not([aria-disabled="true"])'
79
+ );
78
80
  firstElement && (firstElement as HTMLElement).focus();
79
81
  }, 0);
80
82
  }
@@ -46,7 +46,9 @@ export interface MenuItemProps extends Omit<React.HTMLProps<HTMLLIElement>, 'onC
46
46
  actions?: React.ReactNode;
47
47
  /** Description of the menu item */
48
48
  description?: React.ReactNode;
49
- /** Render external link icon */
49
+ /** Render an external link icon on focus or hover, and set the link's
50
+ * "target" attribute to a value of "_blank".
51
+ */
50
52
  isExternalLink?: boolean;
51
53
  /** Flag indicating if the option is selected */
52
54
  isSelected?: boolean;
@@ -191,7 +193,7 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
191
193
  if (flyoutVisible) {
192
194
  const flyoutMenu = (flyoutTarget as HTMLElement).nextElementSibling;
193
195
  const flyoutItems = Array.from(flyoutMenu.getElementsByTagName('UL')[0].children).filter(
194
- el => !(el.classList.contains('pf-m-disabled') || el.classList.contains('pf-c-divider'))
196
+ (el) => !(el.classList.contains('pf-m-disabled') || el.classList.contains('pf-c-divider'))
195
197
  );
196
198
  (flyoutItems[0].firstChild as HTMLElement).focus();
197
199
  } else {
@@ -232,7 +234,7 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
232
234
  let drill: (event: React.KeyboardEvent | React.MouseEvent) => void;
233
235
  if (direction) {
234
236
  if (direction === 'down') {
235
- drill = event =>
237
+ drill = (event) =>
236
238
  onDrillIn &&
237
239
  onDrillIn(
238
240
  event,
@@ -243,7 +245,7 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
243
245
  itemId
244
246
  );
245
247
  } else {
246
- drill = event => onDrillOut && onDrillOut(event, parentMenu, itemId);
248
+ drill = (event) => onDrillOut && onDrillOut(event, parentMenu, itemId);
247
249
  }
248
250
  }
249
251
  let additionalProps = {} as any;
@@ -252,7 +254,8 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
252
254
  href: to,
253
255
  'aria-disabled': isDisabled ? true : null,
254
256
  // prevent invalid 'disabled' attribute on <a> tags
255
- disabled: null
257
+ disabled: null,
258
+ target: isExternalLink ? '_blank' : null
256
259
  };
257
260
  } else if (Component === 'button') {
258
261
  additionalProps = {
@@ -317,7 +320,7 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
317
320
  {...props}
318
321
  >
319
322
  <GenerateId>
320
- {randomId => (
323
+ {(randomId) => (
321
324
  <Component
322
325
  id={id}
323
326
  tabIndex={-1}
@@ -393,7 +396,7 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
393
396
  icon="favorites"
394
397
  isFavorited={isFavorited}
395
398
  aria-label={isFavorited ? 'starred' : 'not starred'}
396
- onClick={event => onActionClick(event, itemId)}
399
+ onClick={(event) => onActionClick(event, itemId)}
397
400
  tabIndex={-1}
398
401
  actionId="fav"
399
402
  />
@@ -67,7 +67,7 @@ To trigger an action when a specific item's action icon is selected, pass in the
67
67
 
68
68
  ### With links
69
69
 
70
- Use the `to` property to add a link to a `<MenuItem>` that directs users to a new page when the item is selected. Use the `isExternalLink` property when linking to external resources. This will annotate a menu item link with an external link icon when they navigate to the link or hover over it.
70
+ Use the `to` property to add a link to a `<MenuItem>` that directs users to a new page when the item is selected. Use the `isExternalLink` property when linking to external resources. This will annotate a menu item link with an external link icon when they navigate to the link or hover over it, as well as add `target="_blank"` so that the link opens in a new tab or window.
71
71
 
72
72
  ```ts file="MenuWithLinks.tsx"
73
73
 
@@ -57,7 +57,8 @@ export const WizardNavItem: React.FunctionComponent<WizardNavItemProps> = ({
57
57
  }
58
58
 
59
59
  const btnProps = {
60
- disabled: isDisabled
60
+ disabled: isDisabled,
61
+ type: 'button' as const
61
62
  };
62
63
 
63
64
  const linkProps = {
@@ -11,6 +11,7 @@ exports[`WizardNavItem should match snapshot (auto-generated) 1`] = `
11
11
  data-ouia-component-id="OUIA-Generated-WizardNavItem-1"
12
12
  data-ouia-component-type="PF4/WizardNavItem"
13
13
  data-ouia-safe="true"
14
+ type="button"
14
15
  />
15
16
  ReactNode
16
17
  </li>
@@ -111,6 +111,7 @@ exports[`Wizard Expandable Nav Wizard should match snapshot 1`] = `
111
111
  data-ouia-component-id="OUIA-Generated-WizardNavItem-7"
112
112
  data-ouia-component-type="PF4/WizardNavItem"
113
113
  data-ouia-safe="true"
114
+ type="button"
114
115
  >
115
116
  A
116
117
  </button>
@@ -125,6 +126,7 @@ exports[`Wizard Expandable Nav Wizard should match snapshot 1`] = `
125
126
  data-ouia-component-id="OUIA-Generated-WizardNavItem-8"
126
127
  data-ouia-component-type="PF4/WizardNavItem"
127
128
  data-ouia-safe="true"
129
+ type="button"
128
130
  >
129
131
  <span
130
132
  class="pf-c-wizard__nav-link-text"
@@ -166,6 +168,7 @@ exports[`Wizard Expandable Nav Wizard should match snapshot 1`] = `
166
168
  data-ouia-component-id="OUIA-Generated-WizardNavItem-9"
167
169
  data-ouia-component-type="PF4/WizardNavItem"
168
170
  data-ouia-safe="true"
171
+ type="button"
169
172
  >
170
173
  B-1
171
174
  </button>
@@ -179,6 +182,7 @@ exports[`Wizard Expandable Nav Wizard should match snapshot 1`] = `
179
182
  data-ouia-component-id="OUIA-Generated-WizardNavItem-10"
180
183
  data-ouia-component-type="PF4/WizardNavItem"
181
184
  data-ouia-safe="true"
185
+ type="button"
182
186
  >
183
187
  B-2
184
188
  </button>
@@ -194,6 +198,7 @@ exports[`Wizard Expandable Nav Wizard should match snapshot 1`] = `
194
198
  data-ouia-component-id="OUIA-Generated-WizardNavItem-11"
195
199
  data-ouia-component-type="PF4/WizardNavItem"
196
200
  data-ouia-safe="true"
201
+ type="button"
197
202
  >
198
203
  C
199
204
  </button>
@@ -207,6 +212,7 @@ exports[`Wizard Expandable Nav Wizard should match snapshot 1`] = `
207
212
  data-ouia-component-id="OUIA-Generated-WizardNavItem-12"
208
213
  data-ouia-component-type="PF4/WizardNavItem"
209
214
  data-ouia-safe="true"
215
+ type="button"
210
216
  >
211
217
  D
212
218
  </button>
@@ -381,6 +387,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
381
387
  data-ouia-component-type="PF4/WizardNavItem"
382
388
  data-ouia-safe="true"
383
389
  id="step-A"
390
+ type="button"
384
391
  >
385
392
  A
386
393
  </button>
@@ -395,6 +402,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
395
402
  data-ouia-component-type="PF4/WizardNavItem"
396
403
  data-ouia-safe="true"
397
404
  id="step-B"
405
+ type="button"
398
406
  >
399
407
  B
400
408
  </button>
@@ -412,6 +420,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
412
420
  data-ouia-component-type="PF4/WizardNavItem"
413
421
  data-ouia-safe="true"
414
422
  id="step-B-1"
423
+ type="button"
415
424
  >
416
425
  B-1
417
426
  </button>
@@ -426,6 +435,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
426
435
  data-ouia-component-type="PF4/WizardNavItem"
427
436
  data-ouia-safe="true"
428
437
  id="step-B-2"
438
+ type="button"
429
439
  >
430
440
  B-2
431
441
  </button>
@@ -442,6 +452,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
442
452
  data-ouia-component-type="PF4/WizardNavItem"
443
453
  data-ouia-safe="true"
444
454
  id="step-C"
455
+ type="button"
445
456
  >
446
457
  C
447
458
  </button>
@@ -456,6 +467,7 @@ exports[`Wizard Wizard should match snapshot 1`] = `
456
467
  data-ouia-component-type="PF4/WizardNavItem"
457
468
  data-ouia-safe="true"
458
469
  id="step-D"
470
+ type="button"
459
471
  >
460
472
  D
461
473
  </button>
@@ -586,6 +598,7 @@ exports[`Wizard bare wiz 1`] = `
586
598
  data-ouia-component-id="OUIA-Generated-WizardNavItem-13"
587
599
  data-ouia-component-type="PF4/WizardNavItem"
588
600
  data-ouia-safe="true"
601
+ type="button"
589
602
  >
590
603
  A
591
604
  </button>