Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: autoalign inside modal #16947

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
79f6542
fix: autoalign inside modal
preetibansalui Jul 11, 2024
dd67a57
feat: minor fixes
preetibansalui Jul 17, 2024
8c89833
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Jul 17, 2024
7fc5d53
Merge branch 'main' into 7565-autoalign-inside-modal
riddhybansal Jul 23, 2024
37dba23
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Aug 14, 2024
55865de
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Aug 28, 2024
fb8a54b
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Aug 30, 2024
6d6641e
fix: test case
preetibansalui Aug 30, 2024
35525b0
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 2, 2024
03d7276
fix: test case
preetibansalui Sep 2, 2024
00620b7
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 3, 2024
b4dfd86
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 5, 2024
edafd6b
fix: test fail
preetibansalui Sep 5, 2024
1262a41
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 6, 2024
9eaf3e0
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 9, 2024
59abc66
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 10, 2024
731d1bb
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 10, 2024
acb599b
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 11, 2024
020598f
fix: avt test case
preetibansalui Sep 11, 2024
809da95
Merge branch 'main' into 7565-autoalign-inside-modal
preetibansalui Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ const ComboBox = forwardRef(
[`${prefix}--list-box--up`]: direction === 'top',
[`${prefix}--combo-box--warning`]: showWarning,
[`${prefix}--combo-box--readonly`]: readOnly,
[`${prefix}--autoalign`]: autoAlign,
});

const titleClasses = cx(`${prefix}--label`, {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ const Dropdown = React.forwardRef(
[`${prefix}--dropdown--readonly`]: readOnly,
[`${prefix}--dropdown--${size}`]: size,
[`${prefix}--list-box--up`]: direction === 'top',
[`${prefix}--dropdown--autoalign`]: autoAlign,
[`${prefix}--autoalign`]: autoAlign,
});

const titleClasses = cx(`${prefix}--label`, {
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ const Menu = forwardRef<HTMLUListElement, MenuProps>(function Menu(
[`${prefix}--menu--shown`]:
(open && !legacyAutoalign) || (position[0] >= 0 && position[1] >= 0),
[`${prefix}--menu--with-icons`]: childContext.state.hasIcons,
[`${prefix}--autoalign`]: !legacyAutoalign,
}
);

Expand Down
76 changes: 74 additions & 2 deletions packages/react/src/components/Modal/Modal.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import Modal from './Modal';
import Button from '../Button';
import Select from '../Select';
import MultiSelect from '../MultiSelect';
import { Checkbox as CheckboxIcon } from '@carbon/icons-react';
import { Popover, PopoverContent } from '../Popover';
import Dropdown from '../Dropdown';
import SelectItem from '../SelectItem';
import TextInput from '../TextInput';
import ComboBox from '../ComboBox';
import mdx from './Modal.mdx';
import {
StructuredListWrapper,
Expand Down Expand Up @@ -295,6 +298,7 @@ export const WithScrollingContent = () => {

export const Playground = ({ numberOfButtons, ...args }) => {
const [open, setOpen] = useState(true);
const [popoverOpen, setPopoverOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>Launch modal</Button>
Expand All @@ -315,25 +319,58 @@ export const Playground = ({ numberOfButtons, ...args }) => {
organization to a URL that you own. A custom domain can be a shared
domain, a shared subdomain, or a shared domain and host.
</p>
<p style={{ marginBottom: '1rem' }}>
Custom domains direct requests for your apps in this Cloud Foundry
organization to a URL that you own. A custom domain can be a shared
domain, a shared subdomain, or a shared domain and host.
</p>
<p style={{ marginBottom: '1rem' }}>
Custom domains direct requests for your apps in this Cloud Foundry
organization to a URL that you own. A custom domain can be a shared
domain, a shared subdomain, or a shared domain and host.
</p>
<p style={{ marginBottom: '1rem' }}>
Custom domains direct requests for your apps in this Cloud Foundry
organization to a URL that you own. A custom domain can be a shared
domain, a shared subdomain, or a shared domain and host.
</p>
<TextInput
data-modal-primary-focus
id="text-input-1"
labelText="Domain name"
placeholder="e.g. github.com"
style={{ marginBottom: '1rem' }}
/>
<Select id="select-1" defaultValue="us-south" labelText="Region">
<Select
id="select-1"
defaultValue="us-south"
labelText="Region"
style={{ marginBottom: '1rem' }}>
<SelectItem value="us-south" text="US South" />
<SelectItem value="us-east" text="US East" />
</Select>

<ComboBox
allowCustomValue
autoAlign={true}
id="carbon-combobox"
items={[
'Apple',
'Orange',
'Banana',
'Pineapple',
'Raspberry',
'Lime',
]}
titleText="ComboBox Example of Floating ui"
/>

<Dropdown
autoAlign={true}
id="default"
style={{ margin: '1rem 0' }}
titleText="Dropdown Example of Floating ui"
helperText="This is some helper text"
// initialSelectedItem={items[1]}
label="Option 1"
items={[
{
Expand Down Expand Up @@ -365,6 +402,24 @@ export const Playground = ({ numberOfButtons, ...args }) => {
itemToString={(item) => (item ? item.text : '')}
direction="top"
/>
<MultiSelect
id="test"
label="Multiselect"
titleText="Multiselect"
helperText="This is some helper text"
autoAlign
items={[
{
id: 'downshift-1-item-0',
text: 'Option 1',
},
{
id: 'downshift-1-item-1',
text: 'Option 2',
},
]}
itemToString={(item) => (item ? item.text : '')}
/>

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean id
Expand All @@ -373,6 +428,23 @@ export const Playground = ({ numberOfButtons, ...args }) => {
condimentum risus. Nulla facilisi. Etiam venenatis molestie tellus.
Quisque consectetur non risus eu rutrum.{' '}
</p>

<Popover align={'bottom-right'} autoAlign open={popoverOpen}>
<div className="playground-trigger">
<CheckboxIcon
onClick={() => {
setPopoverOpen(!popoverOpen);
}}
/>
</div>
<PopoverContent className="p-3">
<h2 className="popover-title">Popover Example</h2>
<p className="popover-details">
This server has 150 GB of block storage remaining.
</p>
</PopoverContent>
</Popover>

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean id
accumsan augue. Phasellus consequat augue vitae tellus tincidunt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ const FilterableMultiSelect = React.forwardRef(function FilterableMultiSelect<
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
[`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused,
[`${prefix}--list-box__wrapper--slug`]: slug,
[`${prefix}--autoalign`]: autoAlign,
}
);
const helperId = !helperText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ const MultiSelect = React.forwardRef(
selectedItems && selectedItems.length > 0,
[`${prefix}--list-box--up`]: direction === 'top',
[`${prefix}--multi-select--readonly`]: readOnly,
[`${prefix}--autoalign`]: autoAlign,
[`${prefix}--multi-select--selectall`]: selectAll,
});

Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/OverflowMenu/next/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ const OverflowMenu = React.forwardRef<HTMLDivElement, OverflowMenuProps>(

const containerClasses = classNames(
className,
`${prefix}--overflow-menu__container`
`${prefix}--overflow-menu__container`,
{ [`${prefix}--autoalign`]: autoAlign }
);

const menuClasses = classNames(
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export const Popover: PopoverComponent = React.forwardRef(
[`${prefix}--popover--drop-shadow`]: dropShadow,
[`${prefix}--popover--high-contrast`]: highContrast,
[`${prefix}--popover--open`]: open,
[`${prefix}--popover--auto-align`]: autoAlign,
[`${prefix}--popover--auto-align ${prefix}--autoalign`]: autoAlign,
[`${prefix}--popover--${currentAlignment}`]: true,
[`${prefix}--popover--tab-tip`]: isTabTip,
},
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/Toggletip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function Toggletip<E extends ElementType = 'span'>({
const id = useId();
const className = cx(`${prefix}--toggletip`, customClassName, {
[`${prefix}--toggletip--open`]: open,
[`${prefix}--autoalign`]: autoAlign,
});
const actions = {
toggle: () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/styles/scss/components/modal/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
}

//removing mask image in case we have dropdown in modal
.#{$prefix}--modal-scroll-content:has(.#{$prefix}--dropdown--autoalign) {
.#{$prefix}--modal-scroll-content:has(.#{$prefix}--autoalign) {
mask-image: none;
}

Expand Down
Loading