@patternfly/react-core 4.202.3 → 4.202.6
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 +24 -0
- package/dist/umd/react-core.css +2691 -2691
- package/package.json +6 -6
- package/src/components/Dropdown/examples/Dropdown.md +62 -24
- package/src/components/Select/examples/Select.md +91 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.202.
|
|
3
|
+
"version": "4.202.6",
|
|
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",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.53.
|
|
38
|
-
"@patternfly/react-styles": "^4.52.
|
|
39
|
-
"@patternfly/react-tokens": "^4.54.
|
|
37
|
+
"@patternfly/react-icons": "^4.53.6",
|
|
38
|
+
"@patternfly/react-styles": "^4.52.6",
|
|
39
|
+
"@patternfly/react-tokens": "^4.54.6",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
43
43
|
"tslib": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/patternfly": "4.184.
|
|
46
|
+
"@patternfly/patternfly": "4.184.3",
|
|
47
47
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "dd734c19cd7c9fbc4c2d2923cee34fc440e33c76"
|
|
64
64
|
}
|
|
@@ -444,11 +444,7 @@ const SecondaryDropdown = () => {
|
|
|
444
444
|
onFocus();
|
|
445
445
|
}}
|
|
446
446
|
toggle={
|
|
447
|
-
<DropdownToggle
|
|
448
|
-
onToggle={next => setIsOpen(next)}
|
|
449
|
-
toggleIndicator={CaretDownIcon}
|
|
450
|
-
id="toggle-id-plain-text"
|
|
451
|
-
>
|
|
447
|
+
<DropdownToggle onToggle={next => setIsOpen(next)} toggleIndicator={CaretDownIcon} id="toggle-id-plain-text">
|
|
452
448
|
Dropdown
|
|
453
449
|
</DropdownToggle>
|
|
454
450
|
}
|
|
@@ -1489,53 +1485,95 @@ class ImageTextDropdown extends React.Component {
|
|
|
1489
1485
|
}
|
|
1490
1486
|
```
|
|
1491
1487
|
|
|
1492
|
-
###
|
|
1488
|
+
### Appending document body vs parent
|
|
1489
|
+
|
|
1490
|
+
Avoid passing in `document.body` when passing a value to the `menuAppendTo` prop on the Dropdown component, as it can cause accessibility issues. These issues can include, but are not limited to, being unable to enter the contents of the Dropdown options via assistive technologies (like keyboards or screen readers).
|
|
1491
|
+
|
|
1492
|
+
Instead append to `"parent"` to achieve the same result without sacrificing accessibility.
|
|
1493
|
+
|
|
1494
|
+
In this example, while, after making a selection, both variants retain focus on their respective Dropdown component, the options for the `document.body` variant cannot be navigated to via Voice Over.
|
|
1493
1495
|
|
|
1494
1496
|
```js
|
|
1495
1497
|
import React from 'react';
|
|
1496
|
-
import { Dropdown, DropdownToggle, DropdownItem } from '@patternfly/react-core';
|
|
1498
|
+
import { Dropdown, DropdownToggle, DropdownItem, Flex } from '@patternfly/react-core';
|
|
1497
1499
|
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
1498
1500
|
|
|
1499
|
-
class
|
|
1501
|
+
class DropdownDocumentBodyVsParent extends React.Component {
|
|
1500
1502
|
constructor(props) {
|
|
1501
1503
|
super(props);
|
|
1502
1504
|
this.state = {
|
|
1503
|
-
|
|
1505
|
+
isBodyOpen: false,
|
|
1506
|
+
isParentOpen: false
|
|
1504
1507
|
};
|
|
1505
|
-
this.
|
|
1508
|
+
this.onBodyToggle = isBodyOpen => {
|
|
1506
1509
|
this.setState({
|
|
1507
|
-
|
|
1510
|
+
isBodyOpen
|
|
1508
1511
|
});
|
|
1509
1512
|
};
|
|
1510
|
-
this.
|
|
1513
|
+
this.onBodySelect = event => {
|
|
1511
1514
|
this.setState({
|
|
1512
|
-
|
|
1515
|
+
isBodyOpen: !this.state.isBodyOpen
|
|
1513
1516
|
});
|
|
1514
|
-
this.
|
|
1517
|
+
this.onBodyFocus();
|
|
1515
1518
|
};
|
|
1516
|
-
this.
|
|
1517
|
-
const element = document.getElementById('toggle-id-
|
|
1519
|
+
this.onBodyFocus = () => {
|
|
1520
|
+
const element = document.getElementById('toggle-id-document-body');
|
|
1521
|
+
element.focus();
|
|
1522
|
+
};
|
|
1523
|
+
|
|
1524
|
+
this.onParentToggle = isParentOpen => {
|
|
1525
|
+
this.setState({
|
|
1526
|
+
isParentOpen
|
|
1527
|
+
});
|
|
1528
|
+
};
|
|
1529
|
+
this.onParentSelect = event => {
|
|
1530
|
+
this.setState({
|
|
1531
|
+
isParentOpen: !this.state.isParentOpen
|
|
1532
|
+
});
|
|
1533
|
+
this.onParentFocus();
|
|
1534
|
+
};
|
|
1535
|
+
this.onParentFocus = () => {
|
|
1536
|
+
const element = document.getElementById('toggle-id-parent');
|
|
1518
1537
|
element.focus();
|
|
1519
1538
|
};
|
|
1520
1539
|
}
|
|
1521
1540
|
|
|
1522
1541
|
render() {
|
|
1523
|
-
const {
|
|
1524
|
-
const dropdownItems = [
|
|
1542
|
+
const { isBodyOpen, isParentOpen } = this.state;
|
|
1543
|
+
const dropdownItems = [
|
|
1544
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
1545
|
+
<DropdownItem key="action" component="button">
|
|
1546
|
+
Action
|
|
1547
|
+
</DropdownItem>,
|
|
1548
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
1549
|
+
Disabled link
|
|
1550
|
+
</DropdownItem>
|
|
1551
|
+
];
|
|
1525
1552
|
return (
|
|
1526
|
-
<
|
|
1553
|
+
<Flex>
|
|
1527
1554
|
<Dropdown
|
|
1528
|
-
onSelect={this.
|
|
1555
|
+
onSelect={this.onBodySelect}
|
|
1529
1556
|
toggle={
|
|
1530
|
-
<DropdownToggle id="toggle-id-
|
|
1531
|
-
Dropdown
|
|
1557
|
+
<DropdownToggle id="toggle-id-document-body" onToggle={this.onBodyToggle} toggleIndicator={CaretDownIcon}>
|
|
1558
|
+
Dropdown - Document Body
|
|
1532
1559
|
</DropdownToggle>
|
|
1533
1560
|
}
|
|
1534
|
-
isOpen={
|
|
1561
|
+
isOpen={isBodyOpen}
|
|
1535
1562
|
dropdownItems={dropdownItems}
|
|
1536
1563
|
menuAppendTo={() => document.body}
|
|
1537
1564
|
/>
|
|
1538
|
-
|
|
1565
|
+
<Dropdown
|
|
1566
|
+
onSelect={this.onParentSelect}
|
|
1567
|
+
toggle={
|
|
1568
|
+
<DropdownToggle id="toggle-id-parent" onToggle={this.onParentToggle} toggleIndicator={CaretDownIcon}>
|
|
1569
|
+
Dropdown - Parent
|
|
1570
|
+
</DropdownToggle>
|
|
1571
|
+
}
|
|
1572
|
+
isOpen={isParentOpen}
|
|
1573
|
+
dropdownItems={dropdownItems}
|
|
1574
|
+
menuAppendTo="parent"
|
|
1575
|
+
/>
|
|
1576
|
+
</Flex>
|
|
1539
1577
|
);
|
|
1540
1578
|
}
|
|
1541
1579
|
}
|
|
@@ -2210,79 +2210,122 @@ class SingleSelectInput extends React.Component {
|
|
|
2210
2210
|
}
|
|
2211
2211
|
```
|
|
2212
2212
|
|
|
2213
|
-
###
|
|
2213
|
+
### Appending document body vs parent
|
|
2214
|
+
|
|
2215
|
+
Avoid passing in `document.body` when passing a value to the `menuAppendTo` prop on the Select component, as it can cause accessibility issues. These issues can include, but are not limited to, being unable to enter the contents of the Select options via assistive technologies (like keyboards or screen readers).
|
|
2216
|
+
|
|
2217
|
+
Instead append to `"parent"` to achieve the same result without sacrificing accessibility.
|
|
2218
|
+
|
|
2219
|
+
In this example, while, when the dropdown is opened, both Select variants handle focus management within their dropdown contents the same way, you'll notice a difference when you try pressing the Tab key after selecting an option.
|
|
2220
|
+
|
|
2221
|
+
For the `document.body` variant, the focus will be placed at the end of the page, since that is where the dropdown content is appended to in the DOM (rather than focus being placed on the second Select variant as one might expect). For the `"parent"` variant, however, the focus will be placed on the next tab-able element (the "Toggle JS code" button for the code editor in this case).
|
|
2214
2222
|
|
|
2215
2223
|
```js
|
|
2216
2224
|
import React from 'react';
|
|
2217
|
-
import { Select, SelectOption,
|
|
2225
|
+
import { Select, SelectOption, Flex, FlexItem } from '@patternfly/react-core';
|
|
2218
2226
|
|
|
2219
|
-
class
|
|
2227
|
+
class SelectDocumentBodyVsParent extends React.Component {
|
|
2220
2228
|
constructor(props) {
|
|
2221
2229
|
super(props);
|
|
2230
|
+
this.bodyOptions = [
|
|
2231
|
+
<SelectOption key={0} value="Select a title - document body" isPlaceholder />,
|
|
2232
|
+
<SelectOption key={1} value="Mr" />,
|
|
2233
|
+
<SelectOption key={2} value="Miss" />,
|
|
2234
|
+
<SelectOption key={3} value="Mrs" />,
|
|
2235
|
+
<SelectOption key={4} value="Ms" />,
|
|
2236
|
+
<SelectOption key={6} value="Dr" />,
|
|
2237
|
+
<SelectOption key={7} value="Other" />
|
|
2238
|
+
];
|
|
2239
|
+
|
|
2240
|
+
this.parentOptions = [
|
|
2241
|
+
<SelectOption key={0} value="Select a title - parent" isPlaceholder />,
|
|
2242
|
+
<SelectOption key={1} value="Mr" />,
|
|
2243
|
+
<SelectOption key={2} value="Miss" />,
|
|
2244
|
+
<SelectOption key={3} value="Mrs" />,
|
|
2245
|
+
<SelectOption key={4} value="Ms" />,
|
|
2246
|
+
<SelectOption key={6} value="Dr" />,
|
|
2247
|
+
<SelectOption key={7} value="Other" />
|
|
2248
|
+
];
|
|
2222
2249
|
|
|
2223
2250
|
this.state = {
|
|
2224
|
-
|
|
2225
|
-
|
|
2251
|
+
isBodyOpen: false,
|
|
2252
|
+
isParentOpen: false,
|
|
2253
|
+
bodySelected: null,
|
|
2254
|
+
parentSelected: null
|
|
2226
2255
|
};
|
|
2227
2256
|
|
|
2228
|
-
this.
|
|
2257
|
+
this.onBodyToggle = isBodyOpen => {
|
|
2229
2258
|
this.setState({
|
|
2230
|
-
|
|
2259
|
+
isBodyOpen
|
|
2231
2260
|
});
|
|
2232
2261
|
};
|
|
2233
2262
|
|
|
2234
|
-
this.
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2263
|
+
this.onParentToggle = isParentOpen => {
|
|
2264
|
+
this.setState({
|
|
2265
|
+
isParentOpen
|
|
2266
|
+
});
|
|
2267
|
+
};
|
|
2268
|
+
|
|
2269
|
+
this.onBodySelect = (event, selection, isPlaceholder) => {
|
|
2270
|
+
if (isPlaceholder) this.clearSelection();
|
|
2271
|
+
else {
|
|
2272
|
+
this.setState({
|
|
2273
|
+
bodySelected: selection,
|
|
2274
|
+
isBodyOpen: false
|
|
2275
|
+
});
|
|
2276
|
+
console.log('selected on document body:', selection);
|
|
2277
|
+
}
|
|
2278
|
+
};
|
|
2279
|
+
|
|
2280
|
+
this.onParentSelect = (event, selection, isPlaceholder) => {
|
|
2281
|
+
if (isPlaceholder) this.clearSelection();
|
|
2282
|
+
else {
|
|
2283
|
+
this.setState({
|
|
2284
|
+
parentSelected: selection,
|
|
2285
|
+
isParentOpen: false
|
|
2286
|
+
});
|
|
2287
|
+
console.log('selected on parent:', selection);
|
|
2246
2288
|
}
|
|
2247
2289
|
};
|
|
2248
2290
|
|
|
2249
2291
|
this.clearSelection = () => {
|
|
2250
2292
|
this.setState({
|
|
2251
|
-
selected:
|
|
2293
|
+
selected: null,
|
|
2294
|
+
isOpen: false
|
|
2252
2295
|
});
|
|
2253
2296
|
};
|
|
2254
|
-
|
|
2255
|
-
this.options = [
|
|
2256
|
-
<SelectOption key={0} value="Debug" />,
|
|
2257
|
-
<SelectOption key={1} value="Info" />,
|
|
2258
|
-
<SelectOption key={2} value="Warn" />,
|
|
2259
|
-
<SelectOption key={3} value="Error" />
|
|
2260
|
-
];
|
|
2261
2297
|
}
|
|
2262
2298
|
|
|
2263
2299
|
render() {
|
|
2264
|
-
const {
|
|
2265
|
-
|
|
2300
|
+
const { isBodyOpen, isParentOpen, bodySelected, parentSelected } = this.state;
|
|
2301
|
+
|
|
2266
2302
|
return (
|
|
2267
|
-
<
|
|
2268
|
-
<
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2303
|
+
<Flex space={{ default: 'spacerMd' }} direction={{ default: 'column' }}>
|
|
2304
|
+
<FlexItem>
|
|
2305
|
+
<Select
|
|
2306
|
+
aria-label="Select Input for Document Body"
|
|
2307
|
+
onToggle={this.onBodyToggle}
|
|
2308
|
+
onSelect={this.onBodySelect}
|
|
2309
|
+
selections={bodySelected}
|
|
2310
|
+
isOpen={isBodyOpen}
|
|
2311
|
+
menuAppendTo={() => document.body}
|
|
2312
|
+
>
|
|
2313
|
+
{this.bodyOptions}
|
|
2314
|
+
</Select>
|
|
2315
|
+
</FlexItem>
|
|
2316
|
+
<FlexItem>
|
|
2317
|
+
<Select
|
|
2318
|
+
aria-label="Select Input for Parent"
|
|
2319
|
+
onToggle={this.onParentToggle}
|
|
2320
|
+
onSelect={this.onParentSelect}
|
|
2321
|
+
selections={parentSelected}
|
|
2322
|
+
isOpen={isParentOpen}
|
|
2323
|
+
menuAppendTo="parent"
|
|
2324
|
+
>
|
|
2325
|
+
{this.parentOptions}
|
|
2326
|
+
</Select>
|
|
2327
|
+
</FlexItem>
|
|
2328
|
+
</Flex>
|
|
2286
2329
|
);
|
|
2287
2330
|
}
|
|
2288
2331
|
}
|