Skip to content

vscode-table does not always scroll hidden content [bug] #538

@wfabr

Description

@wfabr

The table scrolling is not always activated, even when tabel content is partially hidden.

Proposed fix

    
// Line 201 - vscode-table.js

    _resizeTableBody() {
        let headerHeight = 0;
        let tbodyHeight = 0;
        const tableHeight = this.getBoundingClientRect().height;
        if (this._assignedHeaderElements && this._assignedHeaderElements.length) {
            headerHeight =
                this._assignedHeaderElements[0].getBoundingClientRect().height;
        }
        if (this._assignedBodyElements && this._assignedBodyElements.length) {
            // Fix: scrollHeight gives natural content size vs constrained getBoundingClientRect
            tbodyHeight = this._assignedBodyElements[0].scrollHeight;
        }

        const availableContentHeight = Math.max(0, tableHeight - headerHeight);
        // Fix: was tbodyHeight - headerHeight - tableHeight > 0 (problem calculation)
        const needsScrolling = tbodyHeight > availableContentHeight;

        this._scrollableElement.style.height =
            needsScrolling ? `${availableContentHeight}px` : 'auto';
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions