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

SCKAN-262: fix UI crash for button menu #219

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 1 deletion frontend/src/components/StatementWithProvenances.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import {Box} from "@mui/material";
import StatementForm from "./Forms/StatementForm";
import ProvenancesForm from "./Forms/ProvenanceForm";

const StatementWithProvenances = ({ statement, background = "#fff", refreshStatement, isDisabled } : any) => {

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/Widgets/CustomEntitiesDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from "@mui/material";
import {CheckedItemIcon, CheckedItemIconBG, UncheckedItemIcon} from "../icons";
import HoveredOptionContent from "./HoveredOptionContent";
import ClearOutlinedIcon from "@mui/icons-material/ClearOutlined";
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
import ArrowDropUpIcon from "@mui/icons-material/ArrowDropUp";
import theme from "../../theme/Theme";
Expand Down Expand Up @@ -854,4 +853,4 @@ export default function CustomEntitiesDropdown({
)}
</>
);
}
}
7 changes: 4 additions & 3 deletions frontend/src/components/Widgets/CustomGroupedButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MenuList from "@mui/material/MenuList";
import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl";

export default function GroupedButtons({handleClick, selectedOption, options, selectedIndex, handleMenuItemClick , hasFormat = false, format, disabled}: any) {
export default function GroupedButtons({handleClick, selectedOption, options, selectedIndex, handleMenuItemClick , hasFormat = false, format, isDisabled}: any) {
const anchorRef = React.useRef<HTMLDivElement>(null);
const [open, setOpen] = React.useState(false);

Expand All @@ -31,7 +31,7 @@ export default function GroupedButtons({handleClick, selectedOption, options, se

return (
<FormControl>
<ButtonGroup variant="contained" ref={anchorRef} disabled={disabled}>
<ButtonGroup variant="contained" ref={anchorRef} disabled={isDisabled}>
<Button onClick={handleClick}>{selectedOption}</Button>
<Button
size="small"
Expand All @@ -40,6 +40,7 @@ export default function GroupedButtons({handleClick, selectedOption, options, se
aria-label="select merge strategy"
aria-haspopup="menu"
onClick={handleToggle}
disabled={options?.length > 0 ? false : true}
Copy link
Contributor

@Salam-Dalloul Salam-Dalloul Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @ddelpiano i only have one suggestion here to make the button looks better, for now it looks like this
Screenshot 2024-02-09 at 2 54 16 PM

if we just make an edit for the options passed value to have an initial value as an empty array if it's undefined in here
export default function GroupedButtons({handleClick, selectedOption, options = [], selectedIndex, handleMenuItemClick , hasFormat = false, format, isDisabled}: any) {

and then add the disabled state for ButtonGroup not the Arrow button

<ButtonGroup variant="contained" ref={anchorRef} disabled={options.length === 0 || isDisabled}>

then the button when looks like this
Screenshot 2024-02-09 at 2 55 00 PM

>
<ArrowDropDownIcon />
</Button>
Expand All @@ -65,7 +66,7 @@ export default function GroupedButtons({handleClick, selectedOption, options, se
<Paper sx={{p:3}}>
<ClickAwayListener onClickAway={handleClose}>
<MenuList id="split-button-menu" autoFocusItem>
{options.map((option: string, index: number) => (
{options?.map((option: string, index: number) => (
<MenuItem
key={option}
selected={index === selectedIndex}
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/Widgets/TextfieldWithChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import React from "react";
import TextField from "@mui/material/TextField";
import FormControl from "@mui/material/FormControl";
import { Autocomplete, styled } from "@mui/material";
import Chip from "@mui/material/Chip";
import ClearOutlinedIcon from "@mui/icons-material/ClearOutlined";
import { vars } from "../../theme/variables";
import Box from "@mui/material/Box";
import CustomTextFieldChip from "./CustomTextFieldChip";

Expand Down