Skip to content

Adds tooltips for button components #1699

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

Merged
merged 7 commits into from
May 22, 2025
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
36 changes: 19 additions & 17 deletions client/packages/lowcoder/src/comps/comps/buttonComp/buttonComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
ButtonStyleControl,
} from "./buttonCompConstants";
import { RefControl } from "comps/controls/refControl";

import { Tooltip } from "antd";
import React, { useContext, useEffect, useCallback } from "react";
import { AnimationStyle } from "@lowcoder-ee/comps/controls/styleControlConstants";
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
Expand Down Expand Up @@ -187,22 +187,24 @@ const ButtonView = React.memo((props: ToViewReturn<ChildrenType>) => {
<ButtonCompWrapper $disabled={props.disabled}>
<EditorContext.Consumer>
{(editorState) => (
<Button100
ref={props.viewRef}
$buttonStyle={props.style}
loading={props.loading}
disabled={
props.disabled ||
(!isDefault(props.type) && getForm(editorState, props.form)?.disableSubmit())
}
onClick={handleClick}
>
{props.prefixIcon && <IconWrapper>{props.prefixIcon}</IconWrapper>}
{
props.text || (props.prefixIcon || props.suffixIcon ? undefined : " ") // Avoid button disappearing
}
{props.suffixIcon && <IconWrapper>{props.suffixIcon}</IconWrapper>}
</Button100>
<Tooltip title={props.text}>
<Button100
ref={props.viewRef}
$buttonStyle={props.style}
loading={props.loading}
disabled={
props.disabled ||
(!isDefault(props.type) && getForm(editorState, props.form)?.disableSubmit())
}
onClick={handleClick}
>
{props.prefixIcon && <IconWrapper>{props.prefixIcon}</IconWrapper>}
{
props.text || (props.prefixIcon || props.suffixIcon ? undefined : " ") // Avoid button disappearing
}
{props.suffixIcon && <IconWrapper>{props.suffixIcon}</IconWrapper>}
</Button100>
</Tooltip>
)}
</EditorContext.Consumer>
</ButtonCompWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { BoolControl } from "comps/controls/boolControl";
import { RefControl } from "comps/controls/refControl";
import React, { useContext, useEffect } from "react";
import { EditorContext } from "comps/editorState";
import { Tooltip } from "antd";

const IconWrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -78,20 +79,22 @@ const ToggleTmpComp = (function () {
$showBorder={props.showBorder}
$animationStyle={props.animationStyle}
>
<Button100
ref={props.viewRef}
$buttonStyle={props.style}
loading={props.loading}
disabled={props.disabled}
onClick={() => {
props.onEvent("change");
props.value.onChange(!props.value.value);
}}
>
{props.iconPosition === "right" && text}
{<IconWrapper>{props.value.value ? props.trueIcon : props.falseIcon}</IconWrapper>}
{props.iconPosition === "left" && text}
</Button100>
<Tooltip title={props.value.value ? props.trueText : props.falseText}>
<Button100
ref={props.viewRef}
$buttonStyle={props.style}
loading={props.loading}
disabled={props.disabled}
onClick={() => {
props.onEvent("change");
props.value.onChange(!props.value.value);
}}
>
{props.iconPosition === "right" && text}
{<IconWrapper>{props.value.value ? props.trueIcon : props.falseIcon}</IconWrapper>}
{props.iconPosition === "left" && text}
</Button100>
</Tooltip>
</ButtonCompWrapperStyled>
);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { useEffect, useRef, useState } from "react";
import { useResizeDetector } from "react-resize-detector";

import { useContext } from "react";
import { Tooltip } from "antd";
import { AssetType, IconscoutControl } from "@lowcoder-ee/comps/controls/iconscoutControl";

const Container = styled.div<{ $style: any }>`
Expand Down Expand Up @@ -258,49 +259,51 @@ let ButtonTmpComp = (function () {
: undefined
}
>
<Button100
ref={props.viewRef}
$buttonStyle={props.style}
loading={props.loading}
style={
props.autoHeight
? {
width: "100%",
height: "100%",
aspectRatio: props.aspectRatio,
borderRadius: props.style.radius,
}
: {
aspectRatio: props.aspectRatio,
borderRadius: props.style.radius,
}
}
disabled={
props.disabled ||
(!isDefault(props.type) &&
getForm(editorState, props.form)?.disableSubmit())
}
onClick={() =>
isDefault(props.type)
? props.onEvent("click")
: submitForm(editorState, props.form)
}
>
{props.sourceMode === 'standard' && props.prefixIcon && (
<IconWrapper
$style={{ ...props.style, size: props.iconSize }}
>
{props.prefixIcon}
</IconWrapper>
)}
{props.sourceMode === 'asset-library' && props.iconScoutAsset && (
<IconScoutWrapper
$style={{ ...props.style, size: props.iconSize }}
>
{Boolean(props.iconScoutAsset.value) && <img src={props.iconScoutAsset.value} />}
</IconScoutWrapper>
)}
</Button100>
<Tooltip title={trans("meeting.meetingControlCompName")}>
<Button100
ref={props.viewRef}
$buttonStyle={props.style}
loading={props.loading}
style={
props.autoHeight
? {
width: "100%",
height: "100%",
aspectRatio: props.aspectRatio,
borderRadius: props.style.radius,
}
: {
aspectRatio: props.aspectRatio,
borderRadius: props.style.radius,
}
}
disabled={
props.disabled ||
(!isDefault(props.type) &&
getForm(editorState, props.form)?.disableSubmit())
}
onClick={() =>
isDefault(props.type)
? props.onEvent("click")
: submitForm(editorState, props.form)
}
>
{props.sourceMode === 'standard' && props.prefixIcon && (
<IconWrapper
$style={{ ...props.style, size: props.iconSize }}
>
{props.prefixIcon}
</IconWrapper>
)}
{props.sourceMode === 'asset-library' && props.iconScoutAsset && (
<IconScoutWrapper
$style={{ ...props.style, size: props.iconSize }}
>
{Boolean(props.iconScoutAsset.value) && <img src={props.iconScoutAsset.value} />}
</IconScoutWrapper>
)}
</Button100>
</Tooltip>
</div>
</Container>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { trans } from "i18n";
import { RefControl } from "comps/controls/refControl";
import { migrateOldData } from "comps/generators/simpleGenerators";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";
import Tooltip from "antd/es/tooltip";
import { useCallback, useRef, useEffect, memo } from "react";

export const getStyle = (style: CheckboxStyleType) => {
Expand Down Expand Up @@ -155,7 +156,7 @@ const MemoizedCheckboxGroup = memo(({
disabled: boolean;
style: CheckboxStyleType;
layout: ValueFromOption<typeof RadioLayoutOptions>;
options: Array<{ label: string; value: string; disabled?: boolean }>;
options: Array<{ label: any; value: string; disabled?: boolean }>;
onChange: (values: string[]) => void;
viewRef: React.Ref<HTMLDivElement>;
tabIndex?: number
Expand Down Expand Up @@ -230,7 +231,11 @@ let CheckboxBasicComp = (function () {
return props.options
.filter((option) => option.value !== undefined && !option.hidden)
.map((option) => ({
label: option.label,
label: (
<Tooltip title={option.label}>
<span>{option.label}</span>
</Tooltip>
),
value: option.value,
disabled: option.disabled,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EllipsisTextCss, ValueFromOption } from "lowcoder-design";
import { trans } from "i18n";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";
import { migrateOldData } from "comps/generators/simpleGenerators";
import Tooltip from "antd/es/tooltip";
import { useCallback, useRef, useEffect, memo } from "react";

const getStyle = (style: RadioStyleType, inputFieldStyle?:RadioStyleType ) => {
Expand Down Expand Up @@ -133,7 +134,11 @@ const MemoizedRadio = memo(({
return options
.filter((option) => option.value !== undefined && !option.hidden)
.map((option) => ({
label: option.label,
label: (
<Tooltip title={option.label}>
<span>{option.label}</span>
</Tooltip>
),
value: option.value,
disabled: option.disabled,
}));
Expand Down
Loading