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

[WEB-2453] fix: Render on hover only when enabled #5609

Merged
merged 4 commits into from
Sep 20, 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
2 changes: 1 addition & 1 deletion packages/ui/src/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const Tooltip: React.FC<ITooltipProps> = ({
openDelay = 200,
closeDelay,
isMobile = false,
renderByDefault = true,
renderByDefault = true, //FIXME: tooltip should always render on hover and not by default, this is a temporary fix
Copy link
Contributor

Choose a reason for hiding this comment

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

Update the renderByDefault prop value to align with the intended behavior.

The updated comment suggests that the tooltip should always render on hover, not by default. However, the renderByDefault prop is still set to true, which contradicts the comment.

To avoid confusion and ensure consistency between the code and the comment, consider updating the prop value to match the intended behavior:

- renderByDefault = true, //FIXME: tooltip should always render on hover and not by default, this is a temporary fix
+ renderByDefault = false, // Tooltip should always render on hover and not by default

Alternatively, if the current behavior is indeed a temporary fix, provide a clear timeline or reference to the planned changes to address this discrepancy.

If you need any assistance in implementing the intended behavior or have any questions, feel free to reach out. I'm happy to help!

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
renderByDefault = true, //FIXME: tooltip should always render on hover and not by default, this is a temporary fix
renderByDefault = false, // Tooltip should always render on hover and not by default

}) => {
const toolTipRef = useRef<HTMLDivElement | null>(null);

Expand Down
26 changes: 19 additions & 7 deletions web/core/components/dropdowns/buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type DropdownButtonProps = {
tooltipHeading: string;
showTooltip: boolean;
variant: TButtonVariants;
renderToolTipByDefault?: boolean;
};

type ButtonProps = {
Expand All @@ -25,10 +26,20 @@ type ButtonProps = {
tooltipContent: string | React.ReactNode;
tooltipHeading: string;
showTooltip: boolean;
renderToolTipByDefault?: boolean;
};

export const DropdownButton: React.FC<DropdownButtonProps> = (props) => {
const { children, className, isActive, tooltipContent, tooltipHeading, showTooltip, variant } = props;
const {
children,
className,
isActive,
tooltipContent,
renderToolTipByDefault = true,
tooltipHeading,
showTooltip,
variant,
} = props;
const ButtonToRender: React.FC<ButtonProps> = BORDER_BUTTON_VARIANTS.includes(variant)
? BorderButton
: BACKGROUND_BUTTON_VARIANTS.includes(variant)
Expand All @@ -42,14 +53,15 @@ export const DropdownButton: React.FC<DropdownButtonProps> = (props) => {
tooltipContent={tooltipContent}
tooltipHeading={tooltipHeading}
showTooltip={showTooltip}
renderToolTipByDefault={renderToolTipByDefault}
>
{children}
</ButtonToRender>
);
};

const BorderButton: React.FC<ButtonProps> = (props) => {
const { children, className, isActive, tooltipContent, tooltipHeading, showTooltip } = props;
const { children, className, isActive, tooltipContent, renderToolTipByDefault, tooltipHeading, showTooltip } = props;
const { isMobile } = usePlatformOS();

return (
Expand All @@ -58,7 +70,7 @@ const BorderButton: React.FC<ButtonProps> = (props) => {
tooltipContent={tooltipContent}
disabled={!showTooltip}
isMobile={isMobile}
renderByDefault={false}
renderByDefault={renderToolTipByDefault}
>
<div
className={cn(
Expand All @@ -74,15 +86,15 @@ const BorderButton: React.FC<ButtonProps> = (props) => {
};

const BackgroundButton: React.FC<ButtonProps> = (props) => {
const { children, className, tooltipContent, tooltipHeading, showTooltip } = props;
const { children, className, tooltipContent, tooltipHeading, renderToolTipByDefault, showTooltip } = props;
const { isMobile } = usePlatformOS();
return (
<Tooltip
tooltipHeading={tooltipHeading}
tooltipContent={tooltipContent}
disabled={!showTooltip}
isMobile={isMobile}
renderByDefault={false}
renderByDefault={renderToolTipByDefault}
>
<div
className={cn(
Expand All @@ -97,15 +109,15 @@ const BackgroundButton: React.FC<ButtonProps> = (props) => {
};

const TransparentButton: React.FC<ButtonProps> = (props) => {
const { children, className, isActive, tooltipContent, tooltipHeading, showTooltip } = props;
const { children, className, isActive, tooltipContent, tooltipHeading, renderToolTipByDefault, showTooltip } = props;
const { isMobile } = usePlatformOS();
return (
<Tooltip
tooltipHeading={tooltipHeading}
tooltipContent={tooltipContent}
disabled={!showTooltip}
isMobile={isMobile}
renderByDefault={false}
renderByDefault={renderToolTipByDefault}
>
<div
className={cn(
Expand Down
1 change: 1 addition & 0 deletions web/core/components/dropdowns/cycle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const CycleDropdown: React.FC<Props> = observer((props) => {
tooltipContent={selectedName ?? placeholder}
showTooltip={showTooltip}
variant={buttonVariant}
renderToolTipByDefault={renderByDefault}
>
{!hideIcon && <ContrastIcon className="h-3 w-3 flex-shrink-0" />}
{BUTTON_VARIANTS_WITH_TEXT.includes(buttonVariant) && (!!selectedName || !!placeholder) && (
Expand Down
1 change: 1 addition & 0 deletions web/core/components/dropdowns/date-range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export const DateRangeDropdown: React.FC<Props> = (props) => {
}
showTooltip={showTooltip}
variant={buttonVariant}
renderToolTipByDefault={renderByDefault}
>
<span
className={cn("h-full flex items-center justify-center gap-1 rounded-sm flex-grow", buttonFromDateClassName)}
Expand Down
1 change: 1 addition & 0 deletions web/core/components/dropdowns/date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const DateDropdown: React.FC<Props> = (props) => {
tooltipContent={value ? renderFormattedDate(value, formatToken) : "None"}
showTooltip={showTooltip}
variant={buttonVariant}
renderToolTipByDefault={renderByDefault}
>
{!hideIcon && icon}
{BUTTON_VARIANTS_WITH_TEXT.includes(buttonVariant) && (
Expand Down
1 change: 1 addition & 0 deletions web/core/components/dropdowns/estimate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
tooltipContent={selectedEstimate ? selectedEstimate?.value : placeholder}
showTooltip={showTooltip}
variant={buttonVariant}
renderToolTipByDefault={renderByDefault}
>
{!hideIcon && <Triangle className="h-3 w-3 flex-shrink-0" />}
{(selectedEstimate || placeholder) && BUTTON_VARIANTS_WITH_TEXT.includes(buttonVariant) && (
Expand Down
3 changes: 2 additions & 1 deletion web/core/components/dropdowns/member/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Props = {
icon?: LucideIcon;
onClose?: () => void;
renderByDefault?: boolean;
optionsClassName? : string;
optionsClassName?: string;
} & MemberDropdownProps;

export const MemberDropdown: React.FC<Props> = observer((props) => {
Expand Down Expand Up @@ -134,6 +134,7 @@ export const MemberDropdown: React.FC<Props> = observer((props) => {
tooltipContent={tooltipContent ?? `${value?.length ?? 0} assignee${value?.length !== 1 ? "s" : ""}`}
showTooltip={showTooltip}
variant={buttonVariant}
renderToolTipByDefault={renderByDefault}
>
{!hideIcon && <ButtonAvatars showTooltip={showTooltip} userIds={value} icon={icon} />}
{BUTTON_VARIANTS_WITH_TEXT.includes(buttonVariant) && (
Expand Down
1 change: 1 addition & 0 deletions web/core/components/dropdowns/module/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export const ModuleDropdown: React.FC<Props> = observer((props) => {
}
showTooltip={showTooltip}
variant={buttonVariant}
renderToolTipByDefault={renderByDefault}
>
<ButtonContent
disabled={disabled}
Expand Down
11 changes: 8 additions & 3 deletions web/core/components/dropdowns/priority.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ButtonProps = {
placeholder: string;
priority: TIssuePriorities | undefined;
showTooltip: boolean;
renderToolTipByDefault?: boolean;
};

const BorderButton = (props: ButtonProps) => {
Expand All @@ -56,6 +57,7 @@ const BorderButton = (props: ButtonProps) => {
placeholder,
priority,
showTooltip,
renderToolTipByDefault = true,
} = props;

const priorityDetails = ISSUE_PRIORITIES.find((p) => p.key === priority);
Expand All @@ -76,7 +78,7 @@ const BorderButton = (props: ButtonProps) => {
tooltipContent={priorityDetails?.title ?? "None"}
disabled={!showTooltip}
isMobile={isMobile}
renderByDefault={false}
renderByDefault={renderToolTipByDefault}
>
<div
className={cn(
Expand Down Expand Up @@ -137,6 +139,7 @@ const BackgroundButton = (props: ButtonProps) => {
placeholder,
priority,
showTooltip,
renderToolTipByDefault = true,
} = props;

const priorityDetails = ISSUE_PRIORITIES.find((p) => p.key === priority);
Expand All @@ -157,7 +160,7 @@ const BackgroundButton = (props: ButtonProps) => {
tooltipContent={priorityDetails?.title ?? "None"}
disabled={!showTooltip}
isMobile={isMobile}
renderByDefault={false}
renderByDefault={renderToolTipByDefault}
>
<div
className={cn(
Expand Down Expand Up @@ -219,6 +222,7 @@ const TransparentButton = (props: ButtonProps) => {
placeholder,
priority,
showTooltip,
renderToolTipByDefault = true,
} = props;

const priorityDetails = ISSUE_PRIORITIES.find((p) => p.key === priority);
Expand All @@ -239,7 +243,7 @@ const TransparentButton = (props: ButtonProps) => {
tooltipContent={priorityDetails?.title ?? "None"}
disabled={!showTooltip}
isMobile={isMobile}
renderByDefault={false}
renderByDefault={renderToolTipByDefault}
>
<div
className={cn(
Expand Down Expand Up @@ -410,6 +414,7 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
placeholder={placeholder}
showTooltip={showTooltip}
hideText={BUTTON_VARIANTS_WITHOUT_TEXT.includes(buttonVariant)}
renderToolTipByDefault={renderByDefault}
/>
</button>
)}
Expand Down
1 change: 1 addition & 0 deletions web/core/components/dropdowns/project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const ProjectDropdown: React.FC<Props> = observer((props) => {
tooltipContent={selectedProject?.name ?? placeholder}
showTooltip={showTooltip}
variant={buttonVariant}
renderToolTipByDefault={renderByDefault}
>
{!hideIcon && selectedProject && (
<span className="grid place-items-center flex-shrink-0 h-4 w-4">
Expand Down
1 change: 1 addition & 0 deletions web/core/components/dropdowns/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
tooltipContent={selectedState?.name ?? "State"}
showTooltip={showTooltip}
variant={buttonVariant}
renderToolTipByDefault={renderByDefault}
>
{stateLoader ? (
<Spinner className="h-3.5 w-3.5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export const IssuePropertyLabels: React.FC<IIssuePropertyLabels> = observer((pro
tooltipHeading="Labels"
tooltipContent={label?.name ?? ""}
isMobile={isMobile}
renderByDefault={false}
renderByDefault={renderByDefault}
>
<div
key={label?.id}
Expand Down
Loading