Skip to content

Commit

Permalink
chore: added unsafe_zIndex property to InlineDialog (#1757)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftascon authored Mar 20, 2024
1 parent 930a968 commit a3e509f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/components/InlineDialog/InlineDialog.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const INLINE_DIALOG_TRIGGER_SELECTOR = '[data-test-id=fondue-inlineDialog-trigge
const INLINE_DIALOG_SELECTOR = '[data-test-id=fondue-inlineDialog-content]';
const OUTSIDE_DIALOG_BUTTON = '[data-test-id=outside-button]';
const INLINE_DIALOG_UNDERLAY = '[data-test-id=fondue-inlineDialog-underlay]';
const INLINE_DIALOG_CONTENT = '[data-test-id=fondue-inlineDialog-content]';

const InlineDialogComponent = (props: Omit<InlineDialogProps, 'open' | 'anchor' | 'handleClose'>) => {
const [isOpen, setIsOpen] = useState(false);
Expand Down Expand Up @@ -282,4 +283,12 @@ describe('InlineDialog Component', () => {
cy.get(INLINE_DIALOG_UNDERLAY).should('exist');
});
});

describe('Unsafe zIndex', () => {
it('renders with Unsafe custom zIndex', () => {
cy.mount(<InlineDialogComponent unsafe_zIndex={2020} />);
cy.get(INLINE_DIALOG_TRIGGER_SELECTOR).children().eq(0).click();
cy.get(INLINE_DIALOG_CONTENT).parent().should('have.css', 'z-index', '2020');
});
});
});
3 changes: 3 additions & 0 deletions src/components/InlineDialog/InlineDialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export default {
type: 'boolean',
},
zIndex: { table: { disable: true } },
unsafe_zIndex: {
type: 'number',
},
},
} as Meta<InlineDialogProps>;

Expand Down
10 changes: 8 additions & 2 deletions src/components/InlineDialog/InlineDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type InlineDialogProps = Omit<
OverlayProps,
'theme' | 'isDetached' | 'verticalAlignment' | 'withArrow' | 'arrowCustomColors' | 'shadow' | 'isDialog'
> &
Omit<BaseDialogProps, 'darkUnderlay'>;
Omit<BaseDialogProps, 'darkUnderlay'> & { unsafe_zIndex?: number };

export const InlineDialog = ({
children,
Expand All @@ -28,6 +28,12 @@ export const InlineDialog = ({
autoHeight = false,
roundedCorners = true,
width = 360,
/**
* This property is used to override the default zIndex of the overlay.
* This is needed to support the legacy Terrific Modal, which dynamically compounds z-indexes to create a "stacked" modal approach.
* Once the legacy Terrific Modal is removed/refactored to a pre-determined set of z-indexes, this property can be removed as well.
*/
unsafe_zIndex,
}: InlineDialogProps) => {
return (
<Overlay
Expand All @@ -46,11 +52,11 @@ export const InlineDialog = ({
handleClose={handleClose}
role={modality === Modality.NonModal ? 'region' : 'dialog'}
autoHeight={autoHeight}
zIndex={Z_INDEX_MODAL}
roundedCorners={roundedCorners}
borderRadius="small"
shadow="medium"
width={width}
zIndex={unsafe_zIndex || Z_INDEX_MODAL}
>
{children}
</Overlay>
Expand Down

0 comments on commit a3e509f

Please sign in to comment.