Skip to content

Commit

Permalink
Stop duplicate issue layout updates (#5743)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulramesha authored Oct 3, 2024
1 parent bc41b11 commit 8291043
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from "react";
import { Tooltip } from "@plane/ui";
// types
// constants
import { EIssueLayoutTypes,ISSUE_LAYOUTS } from "@/constants/issue";
import { EIssueLayoutTypes, ISSUE_LAYOUTS } from "@/constants/issue";
import { usePlatformOS } from "@/hooks/use-platform-os";
// hooks

Expand All @@ -20,6 +20,12 @@ export const LayoutSelection: React.FC<Props> = (props) => {
const { layouts, onChange, selectedLayout } = props;
const { isMobile } = usePlatformOS();

const handleOnChange = (layoutKey: EIssueLayoutTypes) => {
if (selectedLayout !== layoutKey) {
onChange(layoutKey);
}
};

return (
<div className="flex items-center gap-1 rounded bg-custom-background-80 p-1">
{ISSUE_LAYOUTS.filter((l) => layouts.includes(l.key)).map((layout) => (
Expand All @@ -29,7 +35,7 @@ export const LayoutSelection: React.FC<Props> = (props) => {
className={`group grid h-[22px] w-7 place-items-center overflow-hidden rounded transition-all hover:bg-custom-background-100 ${
selectedLayout == layout.key ? "bg-custom-background-100 shadow-custom-shadow-2xs" : ""
}`}
onClick={() => onChange(layout.key)}
onClick={() => handleOnChange(layout.key)}
>
<layout.icon
size={14}
Expand Down

0 comments on commit 8291043

Please sign in to comment.