Skip to content

Commit 6c06eb3

Browse files
authored
Fixing width issue and scrollbar issue on suggestions on mac (#2075)
## Context Virtual tables weren't rendered properly on mac where the scrollbars have different sizes. ## Proposed solution - Adding a static space of 13px for scrollbars on all platforms. This was tested on Chrome/FF Linux/Windows/Mac and looks reasonable well - Fixing border issue (not related to the scrollbar). Border was cat halfway on wider tables. ## Has this been tested? Manual tests only
1 parent 122d2fe commit 6c06eb3

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

app/client/components/GridView.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,20 +533,25 @@ export default class GridView extends BaseView {
533533
if (this._rowHeights.length > 0) {
534534
this._applyAutoWidth();
535535
this.scrolly.updateSize();
536-
const scrollbarWidth = 22;
536+
537+
// Scrollbars have different widths on different platforms, so we need to re-apply
538+
539+
const scrollSize = scrollBar();
537540
const borderWidth = 2;
538541
const headerHeight = 23;
539542
const maxHeight = this.gridOptions?.maxInlineHeight || 600;
540543
const maxWidth = this.gridOptions?.maxInlineWidth || 800;
541-
const totalHeight = this._rowHeights.reduce((sum, value) => sum + value, 0) + headerHeight + borderWidth;
544+
const totalHeight = this._rowHeights.reduce((sum, value) => sum + value, 0) +
545+
headerHeight + borderWidth + scrollSize.height;
542546
const targetHeight = Math.min(totalHeight, maxHeight);
543547
const widthObs = Observable.create<number>(this, 0);
544548

545549
const updateWidth = () => {
546550
if (this.isDisposed()) { return; }
547551
const fields = this.viewSection.viewFields().all();
548552
const fieldsWidthSum = fields.reduce((sum, field) => sum + field.widthDef.peek(), 0);
549-
const targetWidth = Math.min(fieldsWidthSum + ROW_NUMBER_WIDTH + scrollbarWidth, maxWidth);
553+
554+
const targetWidth = Math.min(fieldsWidthSum + ROW_NUMBER_WIDTH + scrollSize.width, maxWidth);
550555
widthObs.set(targetWidth);
551556
};
552557
updateWidth();
@@ -2490,3 +2495,11 @@ function calcZebra(hex: string) {
24902495
function styleCustomVar(property: string, valueObs: BindableValue<string | number>): DomElementMethod {
24912496
return elem => subscribeElem(elem, valueObs, val => elem.style.setProperty(property, String(val)));
24922497
}
2498+
2499+
function scrollBar(): { width: number; height: number } {
2500+
// Currently this feature is limited to suggestions only in virtual tables, that are showing
2501+
// inline grids. For this sake we can assume that scrollbars are always visible and have
2502+
// standard width/height across all browsers.
2503+
// Tested on Chrome/FF Linux/Windows/MacOS.
2504+
return { width: 13, height: 13 };
2505+
}

app/client/components/ViewLayout.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@
8989
border: 1px solid var(--grist-theme-widget-border, var(--grist-color-dark-grey));
9090
}
9191

92-
.diff .view_data_pane_container {
93-
border: none;
94-
}
95-
9692
@media not print {
9793
.active_section > .view_data_pane_container {
9894
box-shadow: -2px 0 0 0px var(--grist-theme-widget-active-border, var(--grist-color-light-green));

app/client/ui/ProposedChangesPage.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ and is subject to change and withdrawal.`,
209209
),
210210
buildComparisonDetails(this, this.gristDoc, details, proposal.comparison.comparison),
211211
proposal.status.status === "dismissed" ? "DISMISSED" : null,
212-
isReadOnly ? null : cssDataRow(
212+
isReadOnly ? null : cssButtonRow(
213213
applied ? null : primaryButton(
214214
t("Accept"),
215215
dom.on("click", async () => {
@@ -686,6 +686,12 @@ const cssDataRow = styled("div", `
686686
margin: 16px 0px;
687687
font-size: ${vars.mediumFontSize};
688688
color: ${theme.text};
689+
& .view_data_pane_container {
690+
width: max-content;
691+
}
692+
`);
693+
694+
const cssButtonRow = styled(cssDataRow, `
689695
width: 360px;
690696
`);
691697

0 commit comments

Comments
 (0)