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 4 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
40 changes: 21 additions & 19 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 } from "react";
import { AnimationStyle } from "@lowcoder-ee/comps/controls/styleControlConstants";
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
Expand Down Expand Up @@ -139,24 +139,26 @@ const ButtonTmpComp = (function () {
<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={() =>
isDefault(props.type) ? props.onEvent("click") : submitForm(editorState, props.form)
}
>
{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={() =>
isDefault(props.type) ? props.onEvent("click") : submitForm(editorState, props.form)
}
>
{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 ReactResizeDetector 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 @@ -256,54 +257,55 @@ 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 }}
>
<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 }}
>
<img src={props.iconScoutAsset.value} />
</IconScoutWrapper>
)}
</Button100>
</Tooltip>
</div>
</Container>
)}
>
</ReactResizeDetector>
></ReactResizeDetector>
)}
</EditorContext.Consumer>
);
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";

export const getStyle = (style: CheckboxStyleType) => {
return css`
Expand Down Expand Up @@ -182,7 +183,11 @@ let CheckboxBasicComp = (function () {
options={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 { useEffect, useRef } from "react";

const getStyle = (style: RadioStyleType, inputFieldStyle?:RadioStyleType ) => {
Expand Down Expand Up @@ -140,7 +141,11 @@ let RadioBasicComp = (function () {
options={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
Loading