carbon-react 147.4.0 → 147.4.2
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/esm/components/date/__internal__/date-picker/date-picker.component.js +19 -15
- package/esm/components/menu/menu-item/menu-item.style.js +5 -0
- package/lib/components/date/__internal__/date-picker/date-picker.component.js +19 -15
- package/lib/components/menu/menu-item/menu-item.style.js +5 -0
- package/package.json +1 -1
|
@@ -85,23 +85,27 @@ export const DatePicker = ({
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
const handleOnDayKeyDown = (_day, _modifiers, ev) => {
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
setOpen(false);
|
|
93
|
-
onPickerClose?.();
|
|
94
|
-
const input = inputElement.current?.querySelector("input");
|
|
95
|
-
|
|
88
|
+
// timeout added to prevent this handler from interfering with the useFocusPortalContent hook, when the date-range
|
|
89
|
+
// is used inside of a popover-container and it is the last focusable element of the popover-container
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
// we need to manually handle this as the picker may be in a Portal
|
|
96
92
|
/* istanbul ignore else */
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
93
|
+
if (Events.isTabKey(ev) && !Events.isShiftKey(ev)) {
|
|
94
|
+
ev.preventDefault();
|
|
95
|
+
setOpen(false);
|
|
96
|
+
onPickerClose?.();
|
|
97
|
+
const input = inputElement.current?.querySelector("input");
|
|
98
|
+
|
|
99
|
+
/* istanbul ignore else */
|
|
100
|
+
if (input) {
|
|
101
|
+
const elements = Array.from(document.querySelectorAll(defaultFocusableSelectors) || /* istanbul ignore next */[]);
|
|
102
|
+
const elementsInPicker = Array.from(ref.current?.querySelectorAll("button, [tabindex]") || /* istanbul ignore next */[]);
|
|
103
|
+
const filteredElements = elements.filter(el => Number(el.tabIndex) !== -1 && !elementsInPicker.includes(el));
|
|
104
|
+
const nextIndex = filteredElements.indexOf(input) + 1;
|
|
105
|
+
filteredElements[nextIndex]?.focus();
|
|
106
|
+
}
|
|
103
107
|
}
|
|
104
|
-
}
|
|
108
|
+
}, 0);
|
|
105
109
|
};
|
|
106
110
|
useEffect(() => {
|
|
107
111
|
if (selectedDays) {
|
|
@@ -169,6 +169,11 @@ const StyledMenuItemWrapper = styled.a.attrs({
|
|
|
169
169
|
|
|
170
170
|
a:hover,
|
|
171
171
|
button:hover {
|
|
172
|
+
${StyledButton} {
|
|
173
|
+
border-radius: 0;
|
|
174
|
+
background-color: transparent;
|
|
175
|
+
}
|
|
176
|
+
|
|
172
177
|
${!asDiv && css`
|
|
173
178
|
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
174
179
|
color: var(--colorsComponentsMenuYang100);
|
|
@@ -94,23 +94,27 @@ const DatePicker = ({
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
const handleOnDayKeyDown = (_day, _modifiers, ev) => {
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
setOpen(false);
|
|
102
|
-
onPickerClose?.();
|
|
103
|
-
const input = inputElement.current?.querySelector("input");
|
|
104
|
-
|
|
97
|
+
// timeout added to prevent this handler from interfering with the useFocusPortalContent hook, when the date-range
|
|
98
|
+
// is used inside of a popover-container and it is the last focusable element of the popover-container
|
|
99
|
+
setTimeout(() => {
|
|
100
|
+
// we need to manually handle this as the picker may be in a Portal
|
|
105
101
|
/* istanbul ignore else */
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
102
|
+
if (_events.default.isTabKey(ev) && !_events.default.isShiftKey(ev)) {
|
|
103
|
+
ev.preventDefault();
|
|
104
|
+
setOpen(false);
|
|
105
|
+
onPickerClose?.();
|
|
106
|
+
const input = inputElement.current?.querySelector("input");
|
|
107
|
+
|
|
108
|
+
/* istanbul ignore else */
|
|
109
|
+
if (input) {
|
|
110
|
+
const elements = Array.from(document.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors) || /* istanbul ignore next */[]);
|
|
111
|
+
const elementsInPicker = Array.from(ref.current?.querySelectorAll("button, [tabindex]") || /* istanbul ignore next */[]);
|
|
112
|
+
const filteredElements = elements.filter(el => Number(el.tabIndex) !== -1 && !elementsInPicker.includes(el));
|
|
113
|
+
const nextIndex = filteredElements.indexOf(input) + 1;
|
|
114
|
+
filteredElements[nextIndex]?.focus();
|
|
115
|
+
}
|
|
112
116
|
}
|
|
113
|
-
}
|
|
117
|
+
}, 0);
|
|
114
118
|
};
|
|
115
119
|
(0, _react.useEffect)(() => {
|
|
116
120
|
if (selectedDays) {
|
|
@@ -178,6 +178,11 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
178
178
|
|
|
179
179
|
a:hover,
|
|
180
180
|
button:hover {
|
|
181
|
+
${_button.default} {
|
|
182
|
+
border-radius: 0;
|
|
183
|
+
background-color: transparent;
|
|
184
|
+
}
|
|
185
|
+
|
|
181
186
|
${!asDiv && (0, _styledComponents.css)`
|
|
182
187
|
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
183
188
|
color: var(--colorsComponentsMenuYang100);
|