@canonical/react-components 3.0.0 → 3.0.1
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.
|
@@ -64,18 +64,19 @@ const Modal = _ref => {
|
|
|
64
64
|
(0, _react.useEffect)(() => {
|
|
65
65
|
modalRef.current.focus();
|
|
66
66
|
}, [modalRef]);
|
|
67
|
+
const hasCloseButton = !!close;
|
|
67
68
|
(0, _react.useEffect)(() => {
|
|
68
69
|
var _focusableModalElemen;
|
|
69
70
|
focusableModalElements.current = modalRef.current.querySelectorAll(focusableElementSelectors);
|
|
70
71
|
let focusIndex = 0;
|
|
71
72
|
// when the close button is rendered, focus on the 2nd content element and not the close btn.
|
|
72
|
-
if (
|
|
73
|
+
if (hasCloseButton && focusableModalElements.current.length > 1) {
|
|
73
74
|
focusIndex = 1;
|
|
74
75
|
}
|
|
75
76
|
(_focusableModalElemen = focusableModalElements.current[focusIndex]) === null || _focusableModalElemen === void 0 || _focusableModalElemen.focus({
|
|
76
77
|
preventScroll: true
|
|
77
78
|
});
|
|
78
|
-
}, [
|
|
79
|
+
}, [hasCloseButton]);
|
|
79
80
|
(0, _react.useEffect)(() => {
|
|
80
81
|
const keyDown = event => {
|
|
81
82
|
const listener = keyListenersMap.get(event.code);
|
|
@@ -129,7 +130,7 @@ const Modal = _ref => {
|
|
|
129
130
|
}, /*#__PURE__*/_react.default.createElement("h2", {
|
|
130
131
|
className: "p-modal__title",
|
|
131
132
|
id: titleId
|
|
132
|
-
}, title),
|
|
133
|
+
}, title), hasCloseButton && /*#__PURE__*/_react.default.createElement("button", {
|
|
133
134
|
type: "button",
|
|
134
135
|
className: "p-modal__close",
|
|
135
136
|
"aria-label": "Close active modal",
|
|
@@ -58,18 +58,19 @@ export var Modal = _ref => {
|
|
|
58
58
|
useEffect(() => {
|
|
59
59
|
modalRef.current.focus();
|
|
60
60
|
}, [modalRef]);
|
|
61
|
+
var hasCloseButton = !!close;
|
|
61
62
|
useEffect(() => {
|
|
62
63
|
var _focusableModalElemen;
|
|
63
64
|
focusableModalElements.current = modalRef.current.querySelectorAll(focusableElementSelectors);
|
|
64
65
|
var focusIndex = 0;
|
|
65
66
|
// when the close button is rendered, focus on the 2nd content element and not the close btn.
|
|
66
|
-
if (
|
|
67
|
+
if (hasCloseButton && focusableModalElements.current.length > 1) {
|
|
67
68
|
focusIndex = 1;
|
|
68
69
|
}
|
|
69
70
|
(_focusableModalElemen = focusableModalElements.current[focusIndex]) === null || _focusableModalElemen === void 0 || _focusableModalElemen.focus({
|
|
70
71
|
preventScroll: true
|
|
71
72
|
});
|
|
72
|
-
}, [
|
|
73
|
+
}, [hasCloseButton]);
|
|
73
74
|
useEffect(() => {
|
|
74
75
|
var keyDown = event => {
|
|
75
76
|
var listener = keyListenersMap.get(event.code);
|
|
@@ -123,7 +124,7 @@ export var Modal = _ref => {
|
|
|
123
124
|
}, /*#__PURE__*/React.createElement("h2", {
|
|
124
125
|
className: "p-modal__title",
|
|
125
126
|
id: titleId
|
|
126
|
-
}, title),
|
|
127
|
+
}, title), hasCloseButton && /*#__PURE__*/React.createElement("button", {
|
|
127
128
|
type: "button",
|
|
128
129
|
className: "p-modal__close",
|
|
129
130
|
"aria-label": "Close active modal",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"tsc-alias": "1.8.10",
|
|
94
94
|
"typescript": "5.7.3",
|
|
95
95
|
"typescript-eslint": "8.24.1",
|
|
96
|
-
"vanilla-framework": "4.
|
|
96
|
+
"vanilla-framework": "4.33.0",
|
|
97
97
|
"wait-on": "8.0.2",
|
|
98
98
|
"webpack": "5.98.0"
|
|
99
99
|
},
|