fix: unneccessary ellipsis for page names in view mode (#12032)

This commit is contained in:
arunvjn 2022-03-24 13:14:53 +05:30 committed by GitHub
parent 95776e6454
commit 6c3116b0aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,5 @@
const dsl = require("../../../../fixtures/PageLoadDsl.json"); const dsl = require("../../../../fixtures/PageLoadDsl.json");
const commonlocators = require("../../../../locators/commonlocators.json"); const commonlocators = require("../../../../locators/commonlocators.json");
const pages = require("../../../../locators/Pages.json");
const publish = require("../../../../locators/publishWidgetspage.json"); const publish = require("../../../../locators/publishWidgetspage.json");
const explorerLocators = require("../../../../locators/explorerlocators.json"); const explorerLocators = require("../../../../locators/explorerlocators.json");
@ -31,6 +30,8 @@ describe("Page Load tests", () => {
.parent() .parent()
.parent() .parent()
.parent() .parent()
.parent()
.parent()
.should("have.class", "is-active"); .should("have.class", "is-active");
// Assert active page DSL // Assert active page DSL
cy.get(commonlocators.headingTextStyle).should( cy.get(commonlocators.headingTextStyle).should(
@ -46,6 +47,8 @@ describe("Page Load tests", () => {
.parent() .parent()
.parent() .parent()
.parent() .parent()
.parent()
.parent()
.should("have.class", "is-active"); .should("have.class", "is-active");
// Assert active page DSL // Assert active page DSL
cy.get(commonlocators.headingTextStyle).should( cy.get(commonlocators.headingTextStyle).should(
@ -63,6 +66,8 @@ describe("Page Load tests", () => {
.parent() .parent()
.parent() .parent()
.parent() .parent()
.parent()
.parent()
.should("have.class", "is-active"); .should("have.class", "is-active");
// Assert active page DSL // Assert active page DSL
cy.get(commonlocators.headingTextStyle).should( cy.get(commonlocators.headingTextStyle).should(

View File

@ -92,17 +92,16 @@ function PageTabName({ name }: { name: string }) {
} }
}, [tabNameRef]); }, [tabNameRef]);
return ellipsisActive ? ( return (
<TooltipComponent <TooltipComponent
boundary="viewport" boundary="viewport"
content={name} content={name}
disabled={!ellipsisActive}
maxWidth="400px" maxWidth="400px"
position={Position.BOTTOM} position={Position.BOTTOM}
> >
{tabNameText} {tabNameText}
</TooltipComponent> </TooltipComponent>
) : (
tabNameText
); );
} }

View File

@ -51,7 +51,7 @@ import {
import { Classes as CsClasses } from "components/ads/common"; import { Classes as CsClasses } from "components/ads/common";
import TooltipComponent from "components/ads/Tooltip"; import TooltipComponent from "components/ads/Tooltip";
import { import {
isEllipsisActive, isVerticalEllipsisActive,
truncateString, truncateString,
howMuchTimeBeforeText, howMuchTimeBeforeText,
} from "utils/helpers"; } from "utils/helpers";
@ -764,7 +764,7 @@ export function ApplicationCard(props: ApplicationCardProps) {
isFetching={isFetchingApplications} isFetching={isFetchingApplications}
ref={appNameWrapperRef} ref={appNameWrapperRef}
> >
{isEllipsisActive(appNameWrapperRef?.current) ? ( {isVerticalEllipsisActive(appNameWrapperRef?.current) ? (
<TooltipComponent <TooltipComponent
content={props.application.name} content={props.application.name}
maxWidth="400px" maxWidth="400px"

View File

@ -259,13 +259,12 @@ export const trimTrailingSlash = (path: string) => {
* @param element * @param element
*/ */
export const isEllipsisActive = (element: HTMLElement | null) => { export const isEllipsisActive = (element: HTMLElement | null) => {
return ( return element && element.clientWidth < element.scrollWidth;
element &&
(element.clientWidth < element.scrollWidth ||
element.offsetHeight < element.scrollHeight)
);
}; };
export const isVerticalEllipsisActive = (element: HTMLElement | null) => {
return element && element.clientHeight < element.scrollHeight;
};
/** /**
* converts array to sentences * converts array to sentences
* for e.g - ['Pawan', 'Abhinav', 'Hetu'] --> 'Pawan, Abhinav and Hetu' * for e.g - ['Pawan', 'Abhinav', 'Hetu'] --> 'Pawan, Abhinav and Hetu'