@carbon/react 1.92.0 → 1.92.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.
@@ -243,17 +243,9 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
243
243
  if (!modalContent || !modalContent.classList.contains(`${prefix}--modal-scroll-content`) || !currentActiveNode || !modalContent.contains(currentActiveNode)) {
244
244
  return;
245
245
  }
246
- const lastContent = modalContent.children[modalContent.children.length - 1];
247
- const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
248
- for (const elem of modalContent.children) {
249
- if (elem.contains(currentActiveNode)) {
250
- const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
251
- if (spaceBelow < gradientSpacing) {
252
- modalContent.scrollTop = modalContent.scrollTop + (gradientSpacing - spaceBelow);
253
- }
254
- break;
255
- }
256
- }
246
+ currentActiveNode.scrollIntoView({
247
+ block: 'center'
248
+ });
257
249
  }
258
250
  function closeModal(evt) {
259
251
  if (!onClose || onClose(evt) !== false) {
@@ -207,19 +207,9 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
207
207
  if (!modalContent || !modalContent.classList.contains(`${prefix}--modal-scroll-content`) || !currentActiveNode || !modalContent.contains(currentActiveNode)) {
208
208
  return;
209
209
  }
210
- const lastContent = modalContent.children[modalContent.children.length - 1];
211
- const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
212
-
213
- // eslint-disable-next-line prefer-const -- https://github.com/carbon-design-system/carbon/issues/20071
214
- for (let elem of modalContent.children) {
215
- if (elem.contains(currentActiveNode)) {
216
- const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
217
- if (spaceBelow < gradientSpacing) {
218
- modalContent.scrollTop = modalContent.scrollTop + (gradientSpacing - spaceBelow);
219
- }
220
- break;
221
- }
222
- }
210
+ currentActiveNode.scrollIntoView({
211
+ block: 'center'
212
+ });
223
213
  }
224
214
  const onSecondaryButtonClick = onSecondarySubmit ? onSecondarySubmit : onRequestClose;
225
215
  const modalClasses = cx(`${prefix}--modal`, {
@@ -247,17 +247,9 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
247
247
  if (!modalContent || !modalContent.classList.contains(`${prefix}--modal-scroll-content`) || !currentActiveNode || !modalContent.contains(currentActiveNode)) {
248
248
  return;
249
249
  }
250
- const lastContent = modalContent.children[modalContent.children.length - 1];
251
- const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
252
- for (const elem of modalContent.children) {
253
- if (elem.contains(currentActiveNode)) {
254
- const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
255
- if (spaceBelow < gradientSpacing) {
256
- modalContent.scrollTop = modalContent.scrollTop + (gradientSpacing - spaceBelow);
257
- }
258
- break;
259
- }
260
- }
250
+ currentActiveNode.scrollIntoView({
251
+ block: 'center'
252
+ });
261
253
  }
262
254
  function closeModal(evt) {
263
255
  if (!onClose || onClose(evt) !== false) {
@@ -211,19 +211,9 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
211
211
  if (!modalContent || !modalContent.classList.contains(`${prefix}--modal-scroll-content`) || !currentActiveNode || !modalContent.contains(currentActiveNode)) {
212
212
  return;
213
213
  }
214
- const lastContent = modalContent.children[modalContent.children.length - 1];
215
- const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
216
-
217
- // eslint-disable-next-line prefer-const -- https://github.com/carbon-design-system/carbon/issues/20071
218
- for (let elem of modalContent.children) {
219
- if (elem.contains(currentActiveNode)) {
220
- const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
221
- if (spaceBelow < gradientSpacing) {
222
- modalContent.scrollTop = modalContent.scrollTop + (gradientSpacing - spaceBelow);
223
- }
224
- break;
225
- }
226
- }
214
+ currentActiveNode.scrollIntoView({
215
+ block: 'center'
216
+ });
227
217
  }
228
218
  const onSecondaryButtonClick = onSecondarySubmit ? onSecondarySubmit : onRequestClose;
229
219
  const modalClasses = cx(`${prefix}--modal`, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.92.0",
4
+ "version": "1.92.1",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -139,5 +139,5 @@
139
139
  "**/*.scss",
140
140
  "**/*.css"
141
141
  ],
142
- "gitHead": "8f9dd77c8055a1a1ce36af55298c19c9f8966ab9"
142
+ "gitHead": "b8f0a82e77dab7c49f4ff03127dc588658fff527"
143
143
  }