carbon-react 147.4.1 → 147.4.3

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.
@@ -85,23 +85,27 @@ export const DatePicker = ({
85
85
  }
86
86
  };
87
87
  const handleOnDayKeyDown = (_day, _modifiers, ev) => {
88
- // we need to manually handle this as the picker may be in a Portal
89
- /* istanbul ignore else */
90
- if (Events.isTabKey(ev) && !Events.isShiftKey(ev)) {
91
- ev.preventDefault();
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 (input) {
98
- const elements = Array.from(document.querySelectorAll(defaultFocusableSelectors) || /* istanbul ignore next */[]);
99
- const elementsInPicker = Array.from(ref.current?.querySelectorAll("button, [tabindex]") || /* istanbul ignore next */[]);
100
- const filteredElements = elements.filter(el => Number(el.tabIndex) !== -1 && !elementsInPicker.includes(el));
101
- const nextIndex = filteredElements.indexOf(input) + 1;
102
- filteredElements[nextIndex]?.focus();
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) {
@@ -45,7 +45,6 @@ const StyledContent = styled.div`
45
45
  hasHeader
46
46
  }) => !hasHeader && css`
47
47
  padding-top: 0;
48
- margin-top: -25px;
49
48
  `}
50
49
  `;
51
50
  export default StyledContent;
@@ -105,7 +105,7 @@ export const DialogFullScreen = ({
105
105
  "data-element": "dialog-full-screen",
106
106
  pagesStyling: pagesStyling,
107
107
  role: role
108
- }), dialogTitle(), closeIcon(), /*#__PURE__*/React.createElement(StyledContent, {
108
+ }), title || headerChildren ? dialogTitle() : null, closeIcon(), /*#__PURE__*/React.createElement(StyledContent, {
109
109
  hasHeader: title !== undefined,
110
110
  "data-element": "content",
111
111
  "data-role": "dialog-full-screen-content",
@@ -42,7 +42,6 @@ const StyledDialogFullScreen = styled.div`
42
42
  }) => pagesStyling && css`
43
43
  ${StyledContent} {
44
44
  padding: 0;
45
- margin-top: -25px;
46
45
  }
47
46
 
48
47
  ${StyledIconButton} {
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { PaddingProps } from "styled-system";
3
3
  export interface PageProps extends PaddingProps {
4
4
  /** The title for the page, normally a Heading component. */
5
- title: React.ReactNode;
5
+ title?: React.ReactNode;
6
6
  /** This component supports children. */
7
7
  children: React.ReactNode;
8
8
  /** The ARIA role to be applied to the component */
@@ -31,9 +31,9 @@ const Page = ({
31
31
  }, rest), /*#__PURE__*/React.createElement(StyledPage, _extends({}, tagComponent("page", rest), {
32
32
  ref: styledPageNodeRef,
33
33
  role: role
34
- }), /*#__PURE__*/React.createElement(FullScreenHeading, {
34
+ }), title ? /*#__PURE__*/React.createElement(FullScreenHeading, {
35
35
  hasContent: true
36
- }, title), /*#__PURE__*/React.createElement(StyledPageContent, _extends({
36
+ }, title) : null, /*#__PURE__*/React.createElement(StyledPageContent, _extends({
37
37
  "data-element": "carbon-page-content",
38
38
  "data-role": "page-content",
39
39
  p: "34px 40px"
@@ -94,23 +94,27 @@ const DatePicker = ({
94
94
  }
95
95
  };
96
96
  const handleOnDayKeyDown = (_day, _modifiers, ev) => {
97
- // we need to manually handle this as the picker may be in a Portal
98
- /* istanbul ignore else */
99
- if (_events.default.isTabKey(ev) && !_events.default.isShiftKey(ev)) {
100
- ev.preventDefault();
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 (input) {
107
- const elements = Array.from(document.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors) || /* istanbul ignore next */[]);
108
- const elementsInPicker = Array.from(ref.current?.querySelectorAll("button, [tabindex]") || /* istanbul ignore next */[]);
109
- const filteredElements = elements.filter(el => Number(el.tabIndex) !== -1 && !elementsInPicker.includes(el));
110
- const nextIndex = filteredElements.indexOf(input) + 1;
111
- filteredElements[nextIndex]?.focus();
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) {
@@ -53,7 +53,6 @@ const StyledContent = _styledComponents.default.div`
53
53
  hasHeader
54
54
  }) => !hasHeader && (0, _styledComponents.css)`
55
55
  padding-top: 0;
56
- margin-top: -25px;
57
56
  `}
58
57
  `;
59
58
  var _default = exports.default = StyledContent;
@@ -114,7 +114,7 @@ const DialogFullScreen = ({
114
114
  "data-element": "dialog-full-screen",
115
115
  pagesStyling: pagesStyling,
116
116
  role: role
117
- }), dialogTitle(), closeIcon(), /*#__PURE__*/_react.default.createElement(_content.default, {
117
+ }), title || headerChildren ? dialogTitle() : null, closeIcon(), /*#__PURE__*/_react.default.createElement(_content.default, {
118
118
  hasHeader: title !== undefined,
119
119
  "data-element": "content",
120
120
  "data-role": "dialog-full-screen-content",
@@ -51,7 +51,6 @@ const StyledDialogFullScreen = _styledComponents.default.div`
51
51
  }) => pagesStyling && (0, _styledComponents.css)`
52
52
  ${_content.default} {
53
53
  padding: 0;
54
- margin-top: -25px;
55
54
  }
56
55
 
57
56
  ${_iconButton.default} {
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { PaddingProps } from "styled-system";
3
3
  export interface PageProps extends PaddingProps {
4
4
  /** The title for the page, normally a Heading component. */
5
- title: React.ReactNode;
5
+ title?: React.ReactNode;
6
6
  /** This component supports children. */
7
7
  children: React.ReactNode;
8
8
  /** The ARIA role to be applied to the component */
@@ -40,9 +40,9 @@ const Page = ({
40
40
  }, rest), /*#__PURE__*/_react.default.createElement(_page.StyledPage, _extends({}, (0, _tags.default)("page", rest), {
41
41
  ref: styledPageNodeRef,
42
42
  role: role
43
- }), /*#__PURE__*/_react.default.createElement(_fullScreenHeading.default, {
43
+ }), title ? /*#__PURE__*/_react.default.createElement(_fullScreenHeading.default, {
44
44
  hasContent: true
45
- }, title), /*#__PURE__*/_react.default.createElement(_page.StyledPageContent, _extends({
45
+ }, title) : null, /*#__PURE__*/_react.default.createElement(_page.StyledPageContent, _extends({
46
46
  "data-element": "carbon-page-content",
47
47
  "data-role": "page-content",
48
48
  p: "34px 40px"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "147.4.1",
3
+ "version": "147.4.3",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",