Skip to content

Commit 996de94

Browse files
authored
fix(ui5-flexible-column-layout): column visibility issue fixed (#11416)
* fix(ui5-flexible-column-layout): collumn visibility issue fixed * fix(ui5-flexible-column-layout): apply feedback and other improvements * fix(ui5-flexible-column-layout): remove obsolete comment
1 parent ccd18b1 commit 996de94

File tree

3 files changed

+38
-12
lines changed

3 files changed

+38
-12
lines changed

packages/fiori/cypress/specs/FCL.cy.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ describe("Columns resize", () => {
6969
expect(widthAfterMove).to.be.equal($el.width()!);
7070
});
7171
});
72+
73+
it("sets dedicated class to hidden columns", () => {
74+
cy.get("[ui5-flexible-column-layout]")
75+
.shadow()
76+
.find(".ui5-fcl-column--end")
77+
.should($el => {
78+
expect($el).to.have.class("ui5-fcl-column--hidden");
79+
});
80+
});
7281
});
7382

7483
describe("ACC", () => {

packages/fiori/src/FlexibleColumnLayout.ts

+25-11
Original file line numberDiff line numberDiff line change
@@ -436,25 +436,39 @@ class FlexibleColumnLayout extends UI5Element {
436436

437437
// hide column: 33% to 0, 25% to 0, etc .
438438
if (currentlyHidden) {
439-
// animate the width
440-
columnDOM.style.width = typeof columnWidth === "number" ? `${columnWidth}px` : columnWidth;
441-
442-
// hide column with delay to allow the animation runs entirely
443-
columnDOM.addEventListener("transitionend", this.columnResizeHandler);
444-
439+
this.collapseColumn(columnDOM);
445440
return;
446441
}
447442

448443
// show column: from 0 to 33%, from 0 to 25%, etc.
449444
if (previouslyHidden) {
450-
columnDOM.removeEventListener("transitionend", this.columnResizeHandler);
451-
columnDOM.classList.remove("ui5-fcl-column--hidden");
452-
columnDOM.style.width = typeof columnWidth === "number" ? `${columnWidth}px` : columnWidth;
445+
this.expandColumn(columnDOM, columnWidth);
446+
}
447+
}
448+
449+
expandColumn(columnDOM: HTMLElement, columnWidth: string | number) {
450+
columnDOM.classList.remove("ui5-fcl-column--hidden");
451+
columnDOM.style.width = typeof columnWidth === "number" ? `${columnWidth}px` : columnWidth;
452+
}
453+
454+
collapseColumn(columnDOM: HTMLElement) {
455+
const hasAnimation = getAnimationMode() !== AnimationMode.None && !this.initialRendering;
456+
columnDOM.style.width = "0px";
457+
458+
if (hasAnimation) {
459+
// hide column with delay to allow the animation runs entirely
460+
columnDOM.classList.add("ui5-fcl-column-collapse-animation");
461+
columnDOM.addEventListener("transitionend", this.onColumnCollapseAnimationEnd);
462+
} else {
463+
columnDOM.classList.add("ui5-fcl-column--hidden");
453464
}
454465
}
455466

456-
columnResizeHandler = (e: Event) => {
457-
(e.target as HTMLElement).classList.add("ui5-fcl-column--hidden");
467+
onColumnCollapseAnimationEnd = (e: Event) => {
468+
const columnDOM = e.target as HTMLElement;
469+
columnDOM.classList.add("ui5-fcl-column--hidden");
470+
columnDOM.classList.remove("ui5-fcl-column-collapse-animation");
471+
columnDOM.removeEventListener("transitionend", this.onColumnCollapseAnimationEnd);
458472
}
459473

460474
nextColumnLayout(layout: `${FCLLayout}`) {

packages/fiori/src/themes/FlexibleColumnLayout.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
box-sizing: border-box;
1818
will-change: width;
1919
overflow-y: auto;
20-
min-width: 15.5rem; /* as noted in our documentation */
2120
}
2221

2322
/* disable pointer events on columns while dragging the separator
@@ -30,6 +29,10 @@
3029
transition: width 560ms cubic-bezier(0.1, 0, 0.05, 1), visibility 560ms ease-in;
3130
}
3231

32+
.ui5-fcl-column:not(.ui5-fcl-column-collapse-animation) {
33+
min-width: 15.5rem; /* as noted in our documentation */
34+
}
35+
3336
.ui5-fcl-column--hidden {
3437
display: none;
3538
}

0 commit comments

Comments
 (0)