@pingux/astro 1.33.0 → 1.33.1-alpha.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.
@@ -126,7 +126,12 @@ var Modal = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
126
126
|
|
127
127
|
var _useDialog = (0, _dialog.useDialog)(contentProps, modalRef),
|
128
128
|
dialogProps = _useDialog.dialogProps,
|
129
|
-
titleProps = _useDialog.titleProps;
|
129
|
+
titleProps = _useDialog.titleProps; // Prevents extra dialog focus from being called.
|
130
|
+
|
131
|
+
|
132
|
+
dialogProps.onMouseDown = function (e) {
|
133
|
+
return e.preventDefault();
|
134
|
+
};
|
130
135
|
|
131
136
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
132
137
|
isDarkMode: others.variant === 'modal.dark'
|
@@ -18,6 +18,13 @@ var _react2 = require("@emotion/react");
|
|
18
18
|
var getComponent = function getComponent() {
|
19
19
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
20
20
|
return (0, _testWrapper.render)((0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.Modal, props)));
|
21
|
+
};
|
22
|
+
|
23
|
+
var getComponentWithCheckbox = function getComponentWithCheckbox() {
|
24
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
25
|
+
return (0, _testWrapper.render)((0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.Modal, props, (0, _react2.jsx)(_index.CheckboxField, {
|
26
|
+
"aria-label": "checkbox"
|
27
|
+
}))));
|
21
28
|
}; // **********
|
22
29
|
// Unit tests
|
23
30
|
// **********
|
@@ -219,4 +226,21 @@ test('should auto focus the first tabbable element if "hasAutoFocus" is true', f
|
|
219
226
|
var button = _testWrapper.screen.queryByRole('button');
|
220
227
|
|
221
228
|
expect(button).toHaveFocus();
|
229
|
+
});
|
230
|
+
test('checkbox should not have focus outline on click', function () {
|
231
|
+
getComponentWithCheckbox({
|
232
|
+
isOpen: true
|
233
|
+
});
|
234
|
+
|
235
|
+
var checkbox = _testWrapper.screen.getByRole('checkbox');
|
236
|
+
|
237
|
+
_userEvent["default"].click(checkbox);
|
238
|
+
|
239
|
+
expect(checkbox).toBeChecked();
|
240
|
+
expect(checkbox).not.toHaveClass('is-focused');
|
241
|
+
|
242
|
+
_userEvent["default"].click(checkbox);
|
243
|
+
|
244
|
+
expect(checkbox).not.toBeChecked();
|
245
|
+
expect(checkbox).not.toHaveClass('is-focused');
|
222
246
|
});
|
@@ -86,7 +86,12 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
86
86
|
|
87
87
|
var _useDialog = useDialog(contentProps, modalRef),
|
88
88
|
dialogProps = _useDialog.dialogProps,
|
89
|
-
titleProps = _useDialog.titleProps;
|
89
|
+
titleProps = _useDialog.titleProps; // Prevents extra dialog focus from being called.
|
90
|
+
|
91
|
+
|
92
|
+
dialogProps.onMouseDown = function (e) {
|
93
|
+
return e.preventDefault();
|
94
|
+
};
|
90
95
|
|
91
96
|
var _useStatusClasses = useStatusClasses(className, {
|
92
97
|
isDarkMode: others.variant === 'modal.dark'
|
@@ -2,13 +2,20 @@ import React from 'react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
3
3
|
import axeTest from '../../../utils/testUtils/testAxe';
|
4
4
|
import { render, screen, queryByAttribute } from '../../../utils/testUtils/testWrapper';
|
5
|
-
import { OverlayProvider, Modal } from '../../../index'; // For testing the modal alone
|
5
|
+
import { CheckboxField, OverlayProvider, Modal } from '../../../index'; // For testing the modal alone
|
6
6
|
|
7
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
8
|
|
9
9
|
var getComponent = function getComponent() {
|
10
10
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
11
11
|
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Modal, props)));
|
12
|
+
};
|
13
|
+
|
14
|
+
var getComponentWithCheckbox = function getComponentWithCheckbox() {
|
15
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
16
|
+
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Modal, props, ___EmotionJSX(CheckboxField, {
|
17
|
+
"aria-label": "checkbox"
|
18
|
+
}))));
|
12
19
|
}; // **********
|
13
20
|
// Unit tests
|
14
21
|
// **********
|
@@ -185,4 +192,16 @@ test('should auto focus the first tabbable element if "hasAutoFocus" is true', f
|
|
185
192
|
});
|
186
193
|
var button = screen.queryByRole('button');
|
187
194
|
expect(button).toHaveFocus();
|
195
|
+
});
|
196
|
+
test('checkbox should not have focus outline on click', function () {
|
197
|
+
getComponentWithCheckbox({
|
198
|
+
isOpen: true
|
199
|
+
});
|
200
|
+
var checkbox = screen.getByRole('checkbox');
|
201
|
+
userEvent.click(checkbox);
|
202
|
+
expect(checkbox).toBeChecked();
|
203
|
+
expect(checkbox).not.toHaveClass('is-focused');
|
204
|
+
userEvent.click(checkbox);
|
205
|
+
expect(checkbox).not.toBeChecked();
|
206
|
+
expect(checkbox).not.toHaveClass('is-focused');
|
188
207
|
});
|