diff --git a/superset-frontend/src/components/EditableTitle/index.tsx b/superset-frontend/src/components/EditableTitle/index.tsx index 6839b45c7d90..ddd85875568a 100644 --- a/superset-frontend/src/components/EditableTitle/index.tsx +++ b/superset-frontend/src/components/EditableTitle/index.tsx @@ -57,6 +57,8 @@ export default function EditableTitle({ placeholder = '', certifiedBy, certificationDetails, + // rest is related to title tooltip + ...rest }: EditableTitleProps) { const [isEditing, setIsEditing] = useState(editing); const [currentTitle, setCurrentTitle] = useState(title); @@ -214,11 +216,7 @@ export default function EditableTitle({ } if (!canEdit) { // don't actually want an input in this case - titleComponent = ( - - {value} - - ); + titleComponent = {value}; } return ( {certifiedBy && ( <> diff --git a/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx b/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx index b1a2efc7b87a..fd5892f42763 100644 --- a/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx @@ -157,6 +157,8 @@ const createProps = () => ({ exportCSV: jest.fn(), onExploreChart: jest.fn(), formData: { slice_id: 1, datasource: '58__table' }, + width: 100, + height: 100, }); test('Should render', () => { diff --git a/superset-frontend/src/dashboard/components/SliceHeader/index.tsx b/superset-frontend/src/dashboard/components/SliceHeader/index.tsx index 88e9a4c69f30..44ddf7b5adef 100644 --- a/superset-frontend/src/dashboard/components/SliceHeader/index.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeader/index.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React, { FC, useMemo } from 'react'; +import React, { FC, useEffect, useMemo, useRef, useState } from 'react'; import { styled, t } from '@superset-ui/core'; import { useUiConfig } from 'src/components/UiConfigContext'; import { Tooltip } from 'src/components/Tooltip'; @@ -41,6 +41,8 @@ type SliceHeaderProps = SliceHeaderControlsProps & { filters: object; handleToggleFullSize: () => void; formData: object; + width: number; + height: number; }; const annotationsLoading = t('Annotation layers are still loading.'); @@ -82,9 +84,13 @@ const SliceHeader: FC = ({ isFullSize, chartStatus, formData, + width, + height, }) => { const dispatch = useDispatch(); const uiConfig = useUiConfig(); + const [headerTooltip, setHeaderTooltip] = useState(null); + const headerRef = useRef(null); // TODO: change to indicator field after it will be implemented const crossFilterValue = useSelector( state => state.dataMask[slice?.slice_id]?.filterState?.value, @@ -98,21 +104,36 @@ const SliceHeader: FC = ({ [crossFilterValue], ); + useEffect(() => { + const headerElement = headerRef.current; + if ( + headerElement && + (headerElement.scrollWidth > headerElement.offsetWidth || + headerElement.scrollHeight > headerElement.offsetHeight) + ) { + setHeaderTooltip(sliceName ?? null); + } else { + setHeaderTooltip(null); + } + }, [sliceName, width, height]); + return (
-
- +
+ + + {!!Object.values(annotationQuery).length && ( {/* @@ -468,7 +479,7 @@ export default class Chart extends React.Component { datasetsStatus={datasetsStatus} />
-
+ ); } } diff --git a/superset-frontend/src/dashboard/stylesheets/dashboard.less b/superset-frontend/src/dashboard/stylesheets/dashboard.less index a3409c4d48bd..b9b2b0aab92f 100644 --- a/superset-frontend/src/dashboard/stylesheets/dashboard.less +++ b/superset-frontend/src/dashboard/stylesheets/dashboard.less @@ -63,12 +63,20 @@ body { display: flex; max-width: 100%; align-items: flex-start; + min-height: 0; & > .header-title { overflow: hidden; text-overflow: ellipsis; max-width: 100%; flex-grow: 1; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + + & > span.ant-tooltip-open { + display: inline; + } } & > .header-controls {