Skip to content

Commit

Permalink
[1062] Make the whole tree item hoverable/clickable but do not select…
Browse files Browse the repository at this point in the history
… when expanding/collapsing from the arrow/chevron

Bug: #1062
Signed-off-by: Pierre-Charles David <[email protected]>
  • Loading branch information
pcdavid committed Nov 18, 2024
1 parent 250022b commit 34e0712
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import { TreeItemDirectEditInput } from './TreeItemDirectEditInput';
import { isFilterCandidate } from './filterTreeItem';
import { useDropTreeItem } from './useDropTreeItem';

const useTreeItemStyle = makeStyles()((theme) => ({
interface TreeItemStyleProps {
depth: number;
}

const useTreeItemStyle = makeStyles<TreeItemStyleProps>()((theme, { depth }) => ({
treeItemBefore: {
height: '2px',
},
Expand All @@ -45,6 +49,7 @@ const useTreeItemStyle = makeStyles()((theme) => ({
borderColor: 'black',
borderStyle: 'dotted',
},
paddingLeft: `${24 * (depth - 1)}px`,
},
treeItemHover: {
backgroundColor: theme.palette.action.hover,
Expand Down Expand Up @@ -92,10 +97,7 @@ const useTreeItemStyle = makeStyles()((theme) => ({
fontWeight: 'bold',
},
ul: {
marginLeft: theme.spacing(3),
},
highlight: {
backgroundColor: theme.palette.navigation.leftBackground,
marginLeft: 0,
},
}));

Expand All @@ -121,7 +123,7 @@ export const TreeItem = ({
markedItemIds,
treeItemActionRender,
}: TreeItemProps) => {
const { classes } = useTreeItemStyle();
const { classes } = useTreeItemStyle({ depth });

const initialState: TreeItemState = {
editingMode: false,
Expand Down Expand Up @@ -361,7 +363,6 @@ export const TreeItem = ({
tabIndex={0}
onKeyDown={onBeginEditing}
draggable={true}
onClick={onClick}
onDragStart={dragStart}
onDragOver={dragOver}
data-treeitemid={item.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const useTreeItemArrowStyle = makeStyles()(() => ({
export const TreeItemArrow = ({ item, depth, onExpand, 'data-testid': dataTestid }: TreeItemArrowProps) => {
const { classes } = useTreeItemArrowStyle();
if (item.hasChildren) {
const onClick = () => onExpand(item.id, depth);
const onClick: React.MouseEventHandler = (event) => {
event.stopPropagation();
onExpand(item.id, depth);
};
if (item.expanded) {
return (
<ExpandMoreIcon className={classes.arrow} style={{ fontSize: 20 }} onClick={onClick} data-testid={dataTestid} />
Expand Down

0 comments on commit 34e0712

Please sign in to comment.