Using the native tooltip component of XbyK in a react component.

Currently I've implemented a custom react component as a component column for a listing page (see, https://docs.kentico.com/documentation/developers-and-admins/customization/extend-the-administration-interface/ui-pages/reference-ui-page-templates/listing-ui-page-template#add-react-components-to-cells).

I would very much like to have a tooltip for a single cell (the cell I'm hovering over is the custom component column I've created).

The documentation of React components in XbyK is quite limited: https://docs.kentico.com/x/8QSiCQ

It covers just the react input components and no other components. Has anyone had experience in implementing the native XbyL tooltip component on react side? Thanks.


Environment

  • Xperience by Kentico version: [31.2.1]

  • .NET version: [10]

Tags:
Components Custom modules React

Answers

Accepted answer

Although I haven't tried this specific scenario, check out the Kentico Community Portal which shows how to use a custom component in a listing table cell:

The important part is the unfortunately undocumented required naming convention.

  • All "table cell" React components must be suffixed with *TableCellComponent
  • When referring to these components in your C# page code, you only use the component prefix name. In this case, Link
const LinkTableCellComponent = ({
  label,
  path,
}: LinkTableCellComponentProps): React.JSX.Element => {
  // ...
};
.AddComponentColumn(nameof(ContentItemLanguageMetadataInfo.ContentItemLanguageMetadataDisplayName),
    "@kentico-community/portal-web-admin/Link",
    modelRetriever: WebPageLinkModelRetriever,
    caption: "Name",
    searchable: true,
    minWidth: 25)

For your example, I think you'll need to make a wrapping component which uses the Tooltip as a child.

Adapting my LinkTableCellComponent to use it would look like this:

import React from 'react';
import { Link, Tooltip } from '@kentico/xperience-admin-components';

interface LinkTableCellComponentProps {
  readonly path: string;
  readonly label: string;
}

const LinkTableCellComponent = ({
  label,
  path,
}: LinkTableCellComponentProps): React.JSX.Element => {
  return (
    <Tooltip tooltipText={path}>
      <Link href={path} text={label} />
    </Tooltip>
  );
};

To response this discussion, you have to login first.