Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 2132085

Browse files
committed
popper MUI working
1 parent fd7a899 commit 2132085

14 files changed

+66
-56
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"react-csv": "2.2.2",
6565
"react-datepicker": "4.8.0",
6666
"react-dom": "18.2.0",
67-
"react-popper": "2.3.0",
6867
"react-select": "5.6.1",
6968
"react-window": "1.8.8",
7069
"zustand": "4.1.4"

src/cdm/HeaderActionModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type HeaderActionResponse = {
55
headerMenuProps: HeaderMenuProps
66
hooks: {
77
setMenuEl: (expanded: null | HTMLElement) => void,
8+
setTypesEl: (expanded: null | HTMLElement) => void,
89
setKeyState: (key: string) => void,
910
keyState: string,
1011
[key: string]: any | ((a: any) => void)

src/components/HeaderMenu.tsx

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { InputType, StyleVariables } from "helpers/Constants";
22
import { dbTrim, c, getLabelHeader } from "helpers/StylesHelper";
33
import AdjustmentsIcon from "components/img/AdjustmentsIcon";
4-
import React, { FocusEventHandler, useEffect, useState } from "react";
5-
import { usePopper } from "react-popper";
4+
import React, { FocusEventHandler, useState } from "react";
65
import Popper from "@mui/material/Popper";
76
import header_action_button_section from "components/headerActions/HeaderActionButtonSection";
87
import header_action_types_section from "components/headerActions/HeaderActiontypesSection";
98
import { ColumnSettingsModal } from "components/modals/columnSettings/ColumnSettingsModal";
9+
import { PopperTypesStyleModifiers } from "components/styles/PopperStyles";
1010
import { TableColumn } from "cdm/FolderModel";
1111
import { HeaderActionResponse } from "cdm/HeaderActionModel";
1212
import { HeaderMenuProps } from "cdm/HeaderModel";
@@ -33,25 +33,18 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
3333
/** Column values */
3434
const [keyState, setkeyState] = useState(dbTrim(key));
3535
const [inputRef, setInputRef] = useState(null);
36-
// Manage type of data
37-
const [typeReferenceElement, setTypeReferenceElement] = useState(null);
38-
const [typePopperElement, setTypePopperElement] = useState(null);
39-
const [showType, setShowType] = useState(false);
40-
41-
// Manage Popper
42-
const open = Boolean(menuEl);
43-
const id = open ? `header-menu-${column.id}` : undefined;
36+
37+
// Manage menu Popper
38+
const openMenu = Boolean(menuEl);
39+
const idMenu = openMenu ? `header-menu-${column.id}` : undefined;
40+
41+
// Manage type Popper
42+
const [typesEl, setTypesEl] = useState<null | HTMLElement>(null);
43+
const [isTypesShown, setTypesIsShown] = useState(false);
44+
const idTypes = isTypesShown ? `types-menu-${column.id}` : undefined;
4445
// Manage errors
4546
const [labelStateInvalid, setLabelStateInvalid] = useState(false);
4647

47-
/** Event driven actions */
48-
// useEffect(() => {
49-
// // Throw event if created changed to expand or collapse the menu
50-
// if (created) {
51-
// setExpanded(true);
52-
// }
53-
// }, [created]);
54-
5548
/**
5649
* Array of action buttons asociated to the header
5750
*/
@@ -60,9 +53,9 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
6053
headerMenuProps: headerMenuProps,
6154
hooks: {
6255
setMenuEl: setMenuEl,
56+
setTypesEl: setTypesEl,
6357
keyState: keyState,
6458
setKeyState: setkeyState,
65-
setShowType: setShowType,
6659
},
6760
};
6861
const headerButtons =
@@ -75,11 +68,6 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
7568
const typesButtons =
7669
header_action_types_section.run(headerActionResponse).buttons;
7770

78-
const typePopper = usePopper(typeReferenceElement, typePopperElement, {
79-
placement: "right",
80-
strategy: "fixed",
81-
});
82-
8371
function persistLabelChange() {
8472
// Update state of altered column
8573
columnActions.alterColumnLabel(column.columnDef as TableColumn, labelState);
@@ -113,9 +101,8 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
113101
};
114102

115103
return (
116-
<Popper id={id} open={open} anchorEl={menuEl}>
104+
<Popper id={idMenu} open={openMenu} anchorEl={menuEl}>
117105
<Box>
118-
<div className="overlay" onClick={() => setMenuEl(null)} />
119106
<div
120107
className={`menu ${c("popper")}`}
121108
style={{
@@ -164,9 +151,11 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
164151
<div style={{ padding: "4px 0px" }}>
165152
<div
166153
className="menu-item sort-button"
167-
onMouseEnter={() => setShowType(true)}
168-
onMouseLeave={() => setShowType(false)}
169-
ref={setTypeReferenceElement}
154+
onMouseEnter={async (event) => {
155+
setTypesEl(event.currentTarget);
156+
setTypesIsShown(true);
157+
}}
158+
onMouseLeave={async () => setTypesIsShown(false)}
170159
>
171160
<span className="svg-icon svg-text icon-margin">
172161
{propertyIcon}
@@ -175,24 +164,21 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
175164
{getLabelHeader(input)}
176165
</span>
177166
</div>
178-
{showType && (
179-
<div
180-
className={`menu ${c("popper")}`}
181-
ref={setTypePopperElement}
182-
onMouseEnter={() => setShowType(true)}
183-
onMouseLeave={() => setShowType(false)}
184-
{...typePopper.attributes.popper}
185-
style={{
186-
...typePopper.styles.popper,
187-
width: 200,
188-
zIndex: 4,
189-
padding: "4px 0px",
190-
}}
191-
>
167+
<Popper
168+
id={idTypes}
169+
open={isTypesShown}
170+
anchorEl={typesEl}
171+
placement="right"
172+
disablePortal={false}
173+
modifiers={PopperTypesStyleModifiers()}
174+
onMouseEnter={async () => setTypesIsShown(true)}
175+
onMouseLeave={async () => setTypesIsShown(false)}
176+
>
177+
<Box className={`menu ${c("popper")}`}>
192178
{/** Childs of typesButtons */}
193179
{typesButtons}
194-
</div>
195-
)}
180+
</Box>
181+
</Popper>
196182
</div>
197183
</>
198184
)}

src/components/headerActions/handlers/types/CheckboxTypeHeaderAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function checkboxTypeComponent(headerActionResponse: HeaderActionResponse) {
3434
);
3535

3636
const checkBoxTypeOnClick = async () => {
37-
hooks.setShowType(false);
37+
hooks.setTypesEl(null);
3838
hooks.setMenuEl(null);
3939
dataActions.parseDataOfColumn(
4040
column.columnDef as TableColumn,

src/components/headerActions/handlers/types/DateTypeHeaderAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function dateTypeComponent(headerActionResponse: HeaderActionResponse) {
3434
);
3535

3636
const dateOnClick = async () => {
37-
hooks.setShowType(false);
37+
hooks.setTypesEl(null);
3838
hooks.setMenuEl(null);
3939
dataActions.parseDataOfColumn(
4040
column.columnDef as TableColumn,

src/components/headerActions/handlers/types/DatetimeTypeHeaderAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function datetimeTypeComponent(headerActionResponse: HeaderActionResponse) {
3939
);
4040

4141
const datetimeOnClick = async () => {
42-
hooks.setShowType(false);
42+
hooks.setTypesEl(null);
4343
hooks.setMenuEl(null);
4444
await dataActions.parseDataOfColumn(
4545
column.columnDef as TableColumn,

src/components/headerActions/handlers/types/FormulaTypeHeaderAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function numberTypeComponent(headerActionResponse: HeaderActionResponse) {
3333
);
3434

3535
const formulaOnClick = async () => {
36-
hooks.setShowType(false);
36+
hooks.setTypesEl(null);
3737
hooks.setMenuEl(null);
3838
dataActions.parseDataOfColumn(
3939
column.columnDef as TableColumn,

src/components/headerActions/handlers/types/NumberTypeHeaderAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function numberTypeComponent(headerActionResponse: HeaderActionResponse) {
3333
);
3434

3535
const numberOnClick = async () => {
36-
hooks.setShowType(false);
36+
hooks.setTypesEl(null);
3737
hooks.setMenuEl(null);
3838
dataActions.parseDataOfColumn(
3939
column.columnDef as TableColumn,

src/components/headerActions/handlers/types/RelationTypeHeaderAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function numberTypeComponent(headerActionResponse: HeaderActionResponse) {
3333
);
3434

3535
const relationOnClick = async () => {
36-
hooks.setShowType(false);
36+
hooks.setTypesEl(null);
3737
hooks.setMenuEl(null);
3838
dataActions.parseDataOfColumn(
3939
column.columnDef as TableColumn,

src/components/headerActions/handlers/types/RollupTypeHeaderAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function rollupTypeComponent(headerActionResponse: HeaderActionResponse) {
3333
);
3434

3535
const rollupOnClick = async () => {
36-
hooks.setShowType(false);
36+
hooks.setTypesEl(null);
3737
hooks.setMenuEl(null);
3838
dataActions.parseDataOfColumn(
3939
column.columnDef as TableColumn,

0 commit comments

Comments
 (0)