From a06df26e4f682da8c5da0a1e8f946064ca7b8a4f Mon Sep 17 00:00:00 2001 From: Preeti Bansal <146315451+preetibansalui@users.noreply.github.com> Date: Wed, 26 Jun 2024 18:36:04 +0530 Subject: [PATCH 1/2] fix: modal overflow of dropdown (#16544) * fix: modal overfloww of dropdown * feat: added example of floating ui in modal --------- Co-authored-by: Gururaj J <89023023+Gururajj77@users.noreply.github.com> --- .../src/components/Modal/Modal.stories.js | 55 +++++++++++++++++++ .../styles/scss/components/modal/_modal.scss | 5 ++ 2 files changed, 60 insertions(+) diff --git a/packages/react/src/components/Modal/Modal.stories.js b/packages/react/src/components/Modal/Modal.stories.js index fb60764d3560..1dcf41f52be8 100644 --- a/packages/react/src/components/Modal/Modal.stories.js +++ b/packages/react/src/components/Modal/Modal.stories.js @@ -322,6 +322,61 @@ export const Playground = ({ numberOfButtons, ...args }) => { + + (item ? item.text : '')} + direction="top" + /> + +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean id + accumsan augue. Phasellus consequat augue vitae tellus tincidunt + posuere. Curabitur justo urna, consectetur vel elit iaculis, ultrices + condimentum risus. Nulla facilisi. Etiam venenatis molestie tellus. + Quisque consectetur non risus eu rutrum.{' '} +

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean id + accumsan augue. Phasellus consequat augue vitae tellus tincidunt + posuere. Curabitur justo urna, consectetur vel elit iaculis, ultrices + condimentum risus. Nulla facilisi. Etiam venenatis molestie tellus. + Quisque consectetur non risus eu rutrum.{' '} +

+ {args.hasScrollingContent && ( <>

diff --git a/packages/styles/scss/components/modal/_modal.scss b/packages/styles/scss/components/modal/_modal.scss index 65bb53799dfd..bd79cccfd024 100644 --- a/packages/styles/scss/components/modal/_modal.scss +++ b/packages/styles/scss/components/modal/_modal.scss @@ -320,6 +320,11 @@ linear-gradient(to top, $layer 0, 2px, transparent 2px); } + //removing mask image in case we have dropdown in modal + .#{$prefix}--modal-scroll-content:has(.#{$prefix}--dropdown--autoalign) { + mask-image: none; + } + // Required so overflow-indicator disappears at end of content .#{$prefix}--modal-scroll-content > *:last-child { margin-block-end: $spacing-06; From 305c274dd0ae6f925df26c361d8f8607f4b959e7 Mon Sep 17 00:00:00 2001 From: Taylor Jones Date: Wed, 26 Jun 2024 09:23:57 -0500 Subject: [PATCH 2/2] fix(combobox): memoize floating ui ref to prevent max call depth (#16866) Co-authored-by: Nikhil Tomar <63502271+2nikhiltom@users.noreply.github.com> --- .../src/components/ComboBox/ComboBox.tsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/react/src/components/ComboBox/ComboBox.tsx b/packages/react/src/components/ComboBox/ComboBox.tsx index 3fa05acf5ae3..9fdf344dd3e5 100644 --- a/packages/react/src/components/ComboBox/ComboBox.tsx +++ b/packages/react/src/components/ComboBox/ComboBox.tsx @@ -13,6 +13,7 @@ import React, { useEffect, useState, useRef, + useMemo, forwardRef, type ReactNode, type ComponentType, @@ -655,6 +656,15 @@ const ComboBox = forwardRef( (helperText && !isFluid && helperTextId) || undefined; + const menuProps = useMemo( + () => + getMenuProps({ + 'aria-label': deprecatedAriaLabel || ariaLabel, + ref: autoAlign ? refs.setFloating : null, + }), + [autoAlign, deprecatedAriaLabel, ariaLabel] + ); + return (

{titleText && ( @@ -674,7 +684,7 @@ const ComboBox = forwardRef( light={light} size={size} warn={warn} - ref={refs.setReference} + ref={autoAlign ? refs.setReference : null} warnText={warnText} warnTextId={warnTextId}>
@@ -686,7 +696,7 @@ const ComboBox = forwardRef( aria-haspopup="listbox" title={textInput?.current?.value} {...getInputProps({ - 'aria-controls': isOpen ? undefined : getMenuProps().id, + 'aria-controls': isOpen ? undefined : menuProps.id, placeholder, ref: { ...mergeRefs(textInput, ref) }, onKeyDown: ( @@ -785,11 +795,7 @@ const ComboBox = forwardRef( />
{normalizedSlug} - + {isOpen ? filterItems(items, itemToString, inputValue).map( (item, index) => {