grommet 2.40.1 → 2.41.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/components/AccordionPanel/AccordionPanel.js +13 -5
- package/components/Button/StyledButtonKind.js +12 -6
- package/components/DataChart/Detail.js +19 -4
- package/components/DataFilter/DataFilter.js +5 -0
- package/components/Drop/DropContainer.js +51 -3
- package/components/FocusedContainer.js +134 -17
- package/components/Grommet/Grommet.js +11 -5
- package/components/MaskedInput/MaskedInput.js +3 -0
- package/components/Menu/Menu.js +3 -3
- package/components/Select/Select.js +22 -15
- package/components/Select/stories/ChildrenRender.js +7 -8
- package/components/SelectMultiple/SelectMultiple.js +8 -6
- package/components/TextInput/TextInput.js +3 -0
- package/contexts/RootsContext.js +23 -5
- package/es6/components/AccordionPanel/AccordionPanel.js +15 -6
- package/es6/components/Button/StyledButtonKind.js +12 -6
- package/es6/components/DataChart/Detail.js +20 -5
- package/es6/components/DataFilter/DataFilter.js +5 -0
- package/es6/components/Drop/DropContainer.js +51 -3
- package/es6/components/FocusedContainer.js +136 -19
- package/es6/components/Grommet/Grommet.js +12 -6
- package/es6/components/MaskedInput/MaskedInput.js +3 -0
- package/es6/components/Menu/Menu.js +3 -3
- package/es6/components/Select/Select.js +22 -15
- package/es6/components/Select/stories/ChildrenRender.js +7 -8
- package/es6/components/SelectMultiple/SelectMultiple.js +8 -6
- package/es6/components/TextInput/TextInput.js +3 -0
- package/es6/contexts/RootsContext.js +20 -3
- package/es6/themes/base.d.ts +1 -0
- package/es6/themes/base.js +1 -0
- package/es6/utils/DOM.js +2 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +22 -22
- package/themes/base.d.ts +1 -0
- package/themes/base.js +1 -0
- package/utils/DOM.js +2 -1
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext, useMemo, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
// When toggling aria-hidden values, we only want to affect elements
|
|
4
4
|
// in the DOM that come from Grommet, so we track those elements in this
|
|
5
|
-
// context value.
|
|
6
|
-
|
|
5
|
+
// context value. We also only want `trapFocus` to apply to the most recently
|
|
6
|
+
// opened Drop/Layer. See FocusedContainer.js
|
|
7
|
+
export var RootsContext = /*#__PURE__*/React.createContext(undefined);
|
|
8
|
+
export var useRoots = function useRoots() {
|
|
9
|
+
// If FocusedContainer is within Grommet React tree, there will be a value
|
|
10
|
+
// from RootsContext. If not, set up a default value that can be passed
|
|
11
|
+
// to drops that might open from within a drop.
|
|
12
|
+
var defaultRoots = useRef([]);
|
|
13
|
+
var defaultValue = useMemo(function () {
|
|
14
|
+
return {
|
|
15
|
+
roots: defaultRoots
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
var existingRoots = useContext(RootsContext);
|
|
19
|
+
return {
|
|
20
|
+
contextValue: existingRoots || defaultValue,
|
|
21
|
+
hasRoots: (existingRoots == null ? void 0 : existingRoots.roots) !== undefined
|
|
22
|
+
};
|
|
23
|
+
};
|
package/es6/themes/base.d.ts
CHANGED
package/es6/themes/base.js
CHANGED
package/es6/utils/DOM.js
CHANGED
|
@@ -153,7 +153,8 @@ export var makeNodeUnfocusable = function makeNodeUnfocusable(node) {
|
|
|
153
153
|
Array.prototype.filter.call(elements || [], function (element) {
|
|
154
154
|
return element.getAttribute(TABINDEX) !== null;
|
|
155
155
|
}).forEach(function (element) {
|
|
156
|
-
|
|
156
|
+
// if TABINDEX_STATE already exists, it's holding the original value
|
|
157
|
+
if (!element.getAttribute(TABINDEX_STATE)) element.setAttribute(TABINDEX_STATE, element.getAttribute(TABINDEX));
|
|
157
158
|
element.setAttribute(TABINDEX, -1);
|
|
158
159
|
});
|
|
159
160
|
// then, if any element is inherently focusable and not handled above,
|