fix: Reverting the previous fix for table scrollbar and hiding vertical scrollbar when needed (#33806)

## Description

Reverting the previous fix for table scrollbar and hiding vertical
scrollbar when needed, with a new fix.

Fixes [#33774](https://github.com/appsmithorg/appsmith/issues/33774)
[#33557](https://github.com/appsmithorg/appsmith/issues/33557)
[#17857](https://github.com/appsmithorg/appsmith/issues/17857)

## Automation

/ok-to-test tags="@tag.Table"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9287519606>
> Commit: f4d3b4e3ef90cca02facbb5f829f64e79a0e4b54
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9287519606&attempt=1"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->













## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
This commit is contained in:
Ankita Kinger 2024-05-30 15:10:02 +05:30 committed by GitHub
parent a94019eb3c
commit 595e7daec3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 19 deletions

View File

@ -24,7 +24,7 @@ describe(
_.agHelper
.GetText(getWidgetSelector(_.draggableWidgets.TEXT))
.then(($text) => {
expect($text).to.eq("7");
expect($text).to.eq("6");
});
_.agHelper.GetNClick(
".t--property-control-defaultrowheight .ads-v2-segmented-control__segments-container:nth-child(2)",
@ -41,7 +41,7 @@ describe(
_.agHelper
.GetText(getWidgetSelector(_.draggableWidgets.TEXT))
.then(($text) => {
expect($text).to.eq("4");
expect($text).to.eq("3");
});
});
},

View File

@ -25,8 +25,7 @@ describe(
cy.get(".t--draggable-tablewidgetv2 .table .simplebar-content").then(
($scrollBox) =>
/* 2 is the scrollbar offset which is needed for virtual table */
expect($scrollBox[0].clientHeight + 2).to.be.equal(tableHeight),
expect($scrollBox[0].clientHeight).to.be.equal(tableHeight),
);
});
},

View File

@ -297,15 +297,9 @@ export function Table(props: TableProps) {
const scrollContainerStyles = useMemo(() => {
return {
height:
props.data.length < props.pageSize
? "100%"
: isHeaderVisible
? props.height -
tableSizes.TABLE_HEADER_HEIGHT -
TABLE_SCROLLBAR_HEIGHT +
SCROLL_BAR_OFFSET
: props.height - TABLE_SCROLLBAR_HEIGHT - SCROLL_BAR_OFFSET,
height: isHeaderVisible
? props.height - tableSizes.TABLE_HEADER_HEIGHT - TABLE_SCROLLBAR_HEIGHT
: props.height - TABLE_SCROLLBAR_HEIGHT - SCROLL_BAR_OFFSET,
width: props.width,
};
}, [
@ -313,8 +307,6 @@ export function Table(props: TableProps) {
props.height,
tableSizes.TABLE_HEADER_HEIGHT,
props.width,
props.data.length,
props.pageSize,
]);
const shouldUseVirtual =

View File

@ -95,9 +95,7 @@ const TableVirtualBodyComponent = React.forwardRef(
innerElementType={props.innerElementType}
itemCount={Math.max(props.rows.length, props.pageSize)}
itemData={props.rows}
itemSize={
props.tableSizes.ROW_HEIGHT + props.tableSizes.ROW_VIRTUAL_OFFSET
}
itemSize={props.tableSizes.ROW_HEIGHT}
outerRef={ref}
width={`calc(100% + ${2 * WIDGET_PADDING}px)`}
>

View File

@ -187,7 +187,9 @@ export default {
tableSizes.COLUMN_HEADER_HEIGHT) /
tableSizes.ROW_HEIGHT;
return pageSize % 1 > 0.3 ? Math.ceil(pageSize) : Math.floor(pageSize);
return pageSize % 1 > 0.3 && props.tableData.length > pageSize
? Math.ceil(pageSize)
: Math.floor(pageSize);
},
//
getProcessedTableData: (props, moment, _) => {