Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(a11y-table): Define a standalone table component #1634

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e2bc914
feat(a11y-table): Define a standalone table component
shadowbas Nov 29, 2024
dc9660a
Add support for th and td templating
shadowbas Dec 2, 2024
0cf0898
Finalize drag and drop
shadowbas Dec 3, 2024
4c962cb
Fix height diff between rows
shadowbas Dec 3, 2024
8f72dc8
Fix reactive model of table
shadowbas Dec 5, 2024
70822a1
fixup! Fix reactive model of table
shadowbas Dec 5, 2024
b3b794e
fixup! fixup! Fix reactive model of table
shadowbas Dec 5, 2024
cb45f95
fixup! fixup! fixup! Fix reactive model of table
shadowbas Dec 5, 2024
45dc036
fixup! fixup! fixup! fixup! Fix reactive model of table
shadowbas Dec 5, 2024
454500a
fixup! fixup! fixup! fixup! fixup! Fix reactive model of table
shadowbas Dec 5, 2024
9a6fb37
fixup! fixup! fixup! fixup! fixup! fixup! Fix reactive model of table
shadowbas Dec 5, 2024
327a026
Fix the ctrl shift and meta key issue
shadowbas Dec 9, 2024
71b8251
fixup! Fix the ctrl shift and meta key issue
shadowbas Dec 9, 2024
543a951
Resize idea and mapOverIndexes craziness
shadowbas Dec 10, 2024
b6d4cc3
fixup! Resize idea and mapOverIndexes craziness
shadowbas Dec 10, 2024
d4f835a
fixup! fixup! Resize idea and mapOverIndexes craziness
shadowbas Dec 10, 2024
6654099
Add flagged column
shadowbas Dec 10, 2024
8c64924
Use BehaviorSubject to update firstRowHeight
shadowbas Dec 11, 2024
5315542
Enrich rows also when rows change
shadowbas Dec 11, 2024
96be53b
Use SelectionModel and remove checkbox select logic from table
shadowbas Dec 11, 2024
990d5c4
Prevent checkbox toggle after checked is set
shadowbas Dec 11, 2024
38a38e1
Fix smaller screen layout
shadowbas Dec 12, 2024
9dc3b3f
Do not deselect for certain actions. Fix bulk action when no item is …
shadowbas Dec 12, 2024
d7fdb16
Revert the directive resizer changes
shadowbas Dec 12, 2024
04fa3ee
Add resizable columns
shadowbas Dec 13, 2024
e0fff28
fixup! Add resizable columns
shadowbas Dec 13, 2024
fec9854
fixup! fixup! Add resizable columns
shadowbas Dec 13, 2024
4ed0215
fixup! fixup! fixup! Add resizable columns
shadowbas Dec 13, 2024
cdb103b
fixup! fixup! fixup! fixup! Add resizable columns
shadowbas Dec 13, 2024
1820eb0
Add some sane column width defaults
shadowbas Dec 13, 2024
3549fe0
Enable ordering of columns on th click
shadowbas Dec 14, 2024
717450a
Reset column width on dblclick
shadowbas Dec 16, 2024
aaadbc7
fixup! Reset column width on dblclick
shadowbas Dec 16, 2024
0bb4a81
Show skeleton when scrolling fast
shadowbas Dec 18, 2024
4dcd7cb
fixup! Show skeleton when scrolling fast
shadowbas Jan 8, 2025
8b6bf21
Fix issue where last selected is set to first item on scroll
shadowbas Jan 10, 2025
b31886e
Figure out how to reset column widths on switching routes
shadowbas Jan 10, 2025
027e62a
fixup! Figure out how to reset column widths on switching routes
shadowbas Jan 10, 2025
48f341f
Recompute column width on window resize
shadowbas Jan 10, 2025
806c0f0
Fix issues that caused build to fail
shadowbas Jan 14, 2025
814349a
Fix freezing caused by too many row height checks
shadowbas Jan 14, 2025
47d3048
fixup! fixup! Figure out how to reset column widths on switching routes
shadowbas Jan 14, 2025
00c86aa
Small typing changes in app.component.ts helpers
shadowbas Jan 14, 2025
d146390
WIP: Fix memory issue and use message display abstraction
shadowbas Jan 21, 2025
7cf600e
Fix date and from columns values
shadowbas Jan 21, 2025
49dc22f
Make row deselect when selected row clicked
shadowbas Jan 21, 2025
400973b
Fix the damn scroll issue finally with trackBy
shadowbas Jan 22, 2025
5012fb7
Improve resize button style
shadowbas Jan 22, 2025
17d6961
Add answered and folder column and fixed message data fn
shadowbas Jan 27, 2025
7a67bba
Disable canvastable dopaint
shadowbas Jan 28, 2025
53b23f4
fixup! Disable canvastable dopaint
shadowbas Jan 28, 2025
f42853e
fixup! fixup! Disable canvastable dopaint
shadowbas Jan 28, 2025
bfe52c0
fixup! fixup! fixup! Disable canvastable dopaint
shadowbas Jan 28, 2025
d8e0fe4
fixup! fixup! fixup! fixup! Disable canvastable dopaint
shadowbas Jan 28, 2025
205a93d
fixup! fixup! fixup! fixup! fixup! Disable canvastable dopaint
shadowbas Jan 28, 2025
2377ad2
fixup! fixup! fixup! fixup! fixup! fixup! Disable canvastable dopaint
shadowbas Jan 28, 2025
f1ee521
fixup! fixup! fixup! fixup! fixup! fixup! fixup! Disable canvastable …
shadowbas Jan 28, 2025
fac4243
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Disable canva…
shadowbas Jan 28, 2025
0b5b286
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Disabl…
shadowbas Jan 28, 2025
79609ad
Fix build issue
shadowbas Jan 28, 2025
65d7148
fixup! Fix build issue
shadowbas Jan 29, 2025
393d2af
fixup! fixup! Fix build issue
shadowbas Jan 29, 2025
67fd747
fixup! fixup! fixup! Fix build issue
shadowbas Feb 4, 2025
7628984
Scroll selected message into view
shadowbas Feb 4, 2025
cb46f0b
Set column px width on user column resize
shadowbas Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/app/accessible-table/accessible-table.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<cdk-virtual-scroll-viewport [itemSize]="firstRowHeight" class="email-viewport">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Rename to virtual-scroll-table.component

<table
tabindex="0" role="group" aria-label="Messages"
class="mat-mdc-table mdc-data-table__table cdk-table mat-sort mat-elevation-z8"
>
<ng-container *ngTemplateOutlet="theadTemplate"></ng-container>

<ng-container *cdkVirtualFor="let item of items; trackBy: trackBy; let $index = index;">
<ng-container *ngTemplateOutlet="tbodyTemplate; context: {$implicit: item, item: item, index: $index}"></ng-container>
</ng-container>

</table>
</cdk-virtual-scroll-viewport>
16 changes: 16 additions & 0 deletions src/app/accessible-table/accessible-table.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
table {
border-collapse: collapse; /* Removes space between table cells */
border-spacing: 0; /* Ensures no extra spacing between cells */
max-width: 100%;
table-layout: fixed;
user-select: none;
width: 100%;
}

cdk-virtual-scroll-viewport {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
110 changes: 110 additions & 0 deletions src/app/accessible-table/accessible-table.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// --------- BEGIN RUNBOX LICENSE ---------
// Copyright (C) 2016-2025 Runbox Solutions AS (runbox.com).
//
// This file is part of Runbox 7.
//
// Runbox 7 is free software: You can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// Runbox 7 is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Runbox 7. If not, see <https://www.gnu.org/licenses/>.
// ---------- END RUNBOX LICENSE ----------

import {
OnDestroy,
ChangeDetectionStrategy,
AfterViewInit,
Component,
ContentChild,
ElementRef,
EventEmitter,
Input,
OnChanges,
Output,
SimpleChanges,
TemplateRef,
ViewChild,
} from '@angular/core';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { CommonModule } from '@angular/common';
import { ScrollingModule, CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { ListRange } from '@angular/cdk/collections';
import { Subscription } from 'rxjs';
import { debounceTime } from 'rxjs/operators';

@Component({
selector: 'app-accessible-table',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Rename to app-virtual-scroll-table

standalone: true, // Make the component standalone
imports: [ScrollingModule, CommonModule, MatCheckboxModule],
templateUrl: './accessible-table.component.html',
styleUrls: ['./accessible-table.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AccessibleTableComponent implements OnDestroy, AfterViewInit, OnChanges {
@ContentChild('tbody', { read: TemplateRef }) tbodyTemplate!: TemplateRef<any> | null;
@ContentChild('thead', { read: TemplateRef }) theadTemplate!: TemplateRef<any> | null;

@ViewChild(CdkVirtualScrollViewport) viewport: CdkVirtualScrollViewport;

@Output() renderedRangeChange = new EventEmitter<ListRange>();
@Input() items: any[] = [];

@Input() scrollToIndex: null | number = null

firstRowHeight: number = 100;

private renderedRangeSub!: Subscription;

constructor(
private elementRef: ElementRef,
) { }

ngAfterViewInit() {
this.renderedRangeSub = this.viewport.renderedRangeStream
.pipe(debounceTime(500))
.subscribe(range => {
this.renderedRangeChange.emit(range)
});

setTimeout(() => {
this.updateFirstRowHeight();
}, 1000)
}

ngOnDestroy(): void {
this.renderedRangeSub?.unsubscribe();
}

ngOnChanges(changes: SimpleChanges): void {
this.updateFirstRowHeight()

if (changes.scrollToIndex && this.items.length > this.scrollToIndex) {
this.doScrollToIndex(this.scrollToIndex)
}
}

trackBy(index: number) {
return index;
}

doScrollToIndex(index: number) {
return this.viewport?.scrollToIndex(index, 'smooth');
}

private updateFirstRowHeight(): void {
this.firstRowHeight = this
.elementRef
.nativeElement
.parentElement
?.querySelector('tbody')
?.offsetHeight
|| this.firstRowHeight;
}
}
Loading
Loading