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

FIX: Tooltips not shown above boolean editors in forms and anywhere in grid 2024.2 #2504

Merged
merged 2 commits into from Mar 1, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions frontend-html/src/gui/Components/Form/FormField.tsx
Expand Up @@ -70,7 +70,7 @@ export interface IFormFieldProps {
export class FormField extends React.Component<IFormFieldProps> {

@observable
toolTip: string | undefined | null;
dynamicToolTip: string | undefined | null;

render() {
const row = getSelectedRow(this.props.property);
Expand All @@ -84,23 +84,23 @@ export class FormField extends React.Component<IFormFieldProps> {
<label
className={S.caption}
style={getCaptionStyle(this.props)}
title={getToolTip(this.props, this.toolTip)}
title={getToolTip(this.props.toolTip, this.dynamicToolTip)}
>
{this.props.caption}
</label>
}
<div
className={S.editor}
style={getFormFieldStyle(this.props)}
title={getToolTip(this.props, this.toolTip)}
title={getToolTip(this.props.toolTip, this.dynamicToolTip)}
>
<FormViewEditor
value={this.props.value}
isRichText={this.props.isRichText}
textualValue={this.props.textualValue}
xmlNode={this.props.xmlNode}
backgroundColor={this.props.backgroundColor}
onTextOverflowChanged={toolTip => this.toolTip = toolTip}
onTextOverflowChanged={toolTip => this.dynamicToolTip = toolTip}
dock={this.props.dock}
/>
{invalidMessage && (
Expand Down Expand Up @@ -172,10 +172,10 @@ export function getFormFieldStyle(props: IFormFieldProps) {
};
}

export function getToolTip(props: IFormFieldProps, toolTip: string | undefined | null){
let finalToolTip = props.toolTip ?? "";
if (toolTip) {
finalToolTip = toolTip + "\n\n" + finalToolTip;
export function getToolTip(propertyToolTip: string | undefined, additionalText: string | undefined | null = "" ){
let finalToolTip = propertyToolTip ?? "";
if (additionalText) {
finalToolTip = additionalText + "\n\n" + finalToolTip;
}
return formatTooltipPlaintext(finalToolTip);
}
Expand Down
Expand Up @@ -24,6 +24,7 @@ import { IOrderByDirection } from "model/entities/types/IOrderingConfiguration";
import { Draggable, DraggableProvided } from "react-beautiful-dnd";
import { action, observable } from "mobx";
import cx from "classnames";
import { formatTooltipPlaintext } from "gui/Components/ToolTip/FormatTooltipText";

const MIN_COLUMN_WIDTH = 30;

Expand All @@ -38,6 +39,7 @@ export class Header extends React.Component<{
columnIndex: number;
orderingDirection: IOrderByDirection;
orderingOrder: number;
tooltip?: string
additionalHeaderContent?: () => React.ReactNode;
onColumnWidthChange: (id: string, newWidth: number) => void;
onColumnWidthChangeFinished: (id: string, newWidth: number) => void;
Expand Down Expand Up @@ -103,6 +105,13 @@ export class Header extends React.Component<{
);
}

getTooltip() {
const formattedTooltip = formatTooltipPlaintext(this.props.tooltip);
return formattedTooltip
? formattedTooltip
: this.props.label;
}

private renderHeader(provided?: DraggableProvided) {
return <div className={S.root} ref={provided?.innerRef} {...provided?.draggableProps}>
<div
Expand All @@ -113,7 +122,7 @@ export class Header extends React.Component<{
onClick={(event) => this.onHeaderClick(event)}
className={cx(S.header, "headerClickable")}
style={this.makeHeaderStyle()}
title={this.props.label}
title={this.getTooltip()}
>
<div
className={cx(S.inHeaderRow, "headerClickable")}>
Expand Down
Expand Up @@ -26,7 +26,7 @@ import { getSelectedRow } from "model/selectors/DataView/getSelectedRow";
import { FormRoot } from "./FormRoot";
import { getSelectedRowId } from "model/selectors/TablePanelView/getSelectedRowId";
import { getRowStateRowBgColor } from "model/selectors/RowState/getRowStateRowBgColor";
import { FormField } from "gui/Components/Form/FormField";
import { FormField, getToolTip } from "gui/Components/Form/FormField";
import { FormSection } from "gui/Components/Form/FormSection";
import { FormLabel } from "gui/Components/Form/FormLabel";
import { RadioButton } from "gui/Components/Form/RadioButton";
Expand Down Expand Up @@ -178,18 +178,20 @@ export class FormBuilder extends React.Component<{
if (property.column === "CheckBox") {
return (
<Provider property={property}>
<CheckBox
fieldDimensions={dimensionsFromProperty(property)}
isHidden={isHidden}
checked={value}
readOnly={!row || isReadOnly(property, rowId)}
onKeyDown={(event) => self.onKeyDown(event)}
subscribeToFocusManager={(radioInput) =>
focusManager.subscribe(radioInput, property!.id, property!.tabIndex)
}
onClick={() => self?.props?.dataView?.formFocusManager.stopAutoFocus()}
labelColor={foreGroundColor}
/>
<div title={getToolTip(property.toolTip)}>
<CheckBox
fieldDimensions={dimensionsFromProperty(property)}
isHidden={isHidden}
checked={value}
readOnly={!row || isReadOnly(property, rowId)}
onKeyDown={(event) => self.onKeyDown(event)}
subscribeToFocusManager={(radioInput) =>
focusManager.subscribe(radioInput, property!.id, property!.tabIndex)
}
onClick={() => self?.props?.dataView?.formFocusManager.stopAutoFocus()}
labelColor={foreGroundColor}
/>
</div>
</Provider>
);
}
Expand Down
Expand Up @@ -60,6 +60,8 @@ import { isMobileLayoutActive } from "model/selectors/isMobileLayoutActive";
import cx from "classnames";
import { getGridFocusManager } from "model/entities/GridFocusManager";
import {getScreenFocusManager} from "../../../../model/selectors/FormScreen/getScreenFocusManager";
import { getTooltip } from "gui/Components/ScreenElements/Table/TableRendering/onClick";
import { formatTooltipPlaintext } from "gui/Components/ToolTip/FormatTooltipText";

interface ITableViewProps {
dataView?: IDataView;
Expand Down Expand Up @@ -409,6 +411,7 @@ class HeaderRenderer implements IHeaderRendererData {
isFirst={args.isFirst}
width={args.columnWidth}
label={header.label}
tooltip={property.toolTip}
orderingDirection={header.ordering}
orderingOrder={header.order + 1}
onColumnWidthChange={this.onColumnWidthChange}
Expand Down
Expand Up @@ -48,7 +48,7 @@ import { MobileFormViewEditor } from "gui/connections/MobileComponents/Form/Mobi
export class MobileFormField extends React.Component<IFormFieldProps> {

@observable
toolTip: string | undefined | null;
dynamicToolTip: string | undefined | null;

render() {
const row = getSelectedRow(this.props.property);
Expand All @@ -62,23 +62,23 @@ export class MobileFormField extends React.Component<IFormFieldProps> {
<label
className={S.caption}
style={getCaptionStyle(this.props)}
title={getToolTip(this.props, this.toolTip)}
title={getToolTip(this.props.toolTip, this.dynamicToolTip)}
>
{this.props.caption}
</label>
}
<div
className={S.editor}
style={getFormFieldStyle(this.props)}
title={getToolTip(this.props, this.toolTip)}
title={getToolTip(this.props.toolTip, this.dynamicToolTip)}
>
<MobileFormViewEditor
value={this.props.value}
isRichText={this.props.isRichText}
textualValue={this.props.textualValue}
xmlNode={this.props.xmlNode}
backgroundColor={this.props.backgroundColor}
onTextOverflowChanged={toolTip => this.toolTip = toolTip}
onTextOverflowChanged={toolTip => this.dynamicToolTip = toolTip}
property={this.props.property!}
/>
{invalidMessage && (
Expand Down