From a3c42875942091e9f9a446981ef1fc2bf4f205a5 Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Thu, 8 Jun 2023 14:10:11 +0200 Subject: [PATCH 1/4] remove zIndex property from props and use increment for that --- app-typescript/components/Dropdown.tsx | 279 ++- app-typescript/components/Layouts/Panel.tsx | 5 +- app-typescript/components/Menu.tsx | 7 +- app-typescript/components/Modal.tsx | 6 +- app-typescript/components/MultiSelect.tsx | 6 +- app-typescript/components/Popover.tsx | 2 - .../components/SelectWithTemplate.tsx | 5 +- app-typescript/components/ShowPopup.tsx | 12 +- app-typescript/components/SubNav.tsx | 12 +- app-typescript/components/TreeSelect.tsx | 5 +- app-typescript/components/WithPopover.tsx | 2 - app-typescript/components/_Positioner.tsx | 9 +- .../components/avatar/avatar-group.tsx | 3 - app-typescript/zIndex.tsx | 5 + .../react-playgrounds/CoreLayout.tsx | 825 ++++----- .../react-playgrounds/EditorTest.tsx | 742 ++++---- .../react-playgrounds/Multiedit.tsx | 464 ++--- .../react-playgrounds/PageLayoutTest.tsx | 56 +- .../react-playgrounds/PersonalProfile.tsx | 12 +- .../react-playgrounds/RundownEditor.tsx | 48 +- .../react-playgrounds/Rundowns.tsx | 1557 +++++++++-------- .../react-playgrounds/SamsPlayground.tsx | 5 +- .../react-playgrounds/UiPlayground.tsx | 5 +- examples/pages/react/CreateButton.tsx | 4 +- examples/pages/react/Dropdowns.tsx | 366 ++-- examples/pages/react/Modal.tsx | 12 - examples/pages/react/MultiSelect.tsx | 1 - examples/pages/react/NavButtons.tsx | 8 +- examples/pages/react/Panel.tsx | 1 - examples/pages/react/Popover.tsx | 12 +- examples/pages/react/SubNav.tsx | 19 +- 31 files changed, 2293 insertions(+), 2202 deletions(-) create mode 100644 app-typescript/zIndex.tsx diff --git a/app-typescript/components/Dropdown.tsx b/app-typescript/components/Dropdown.tsx index 859fe7e8..530ad09b 100644 --- a/app-typescript/components/Dropdown.tsx +++ b/app-typescript/components/Dropdown.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { createPopper } from '@popperjs/core'; import { useId } from "react-id-generator"; +import {getNextZIndex} from './../zIndex'; export interface IMenuItem { label: string | React.ReactNode; @@ -33,9 +34,7 @@ interface IMenu { items: Array; header?: Array; footer?: Array; - append?: boolean; children: React.ReactNode; - zIndex?: number; onChange?(event?: any): void; } @@ -46,11 +45,15 @@ export const Dropdown = ({ header, footer, children, - append, align, - zIndex, onChange, }: IMenu) => { + const [zIndex, setZIndex] = React.useState(-1); + + if (zIndex === -1) { + setZIndex(getNextZIndex()); + } + const [open, setOpen] = React.useState(false); const [change, setChange] = React.useState(false); const [menuID] = useId(); @@ -84,7 +87,7 @@ export const Dropdown = ({ }, [change]); React.useLayoutEffect(() => { - if (append && change) { + if (change) { addInPlaceholder(); } setChange(true); @@ -93,10 +96,11 @@ export const Dropdown = ({ function createAppendMenu() { if (header && footer) { return ( -