-
Notifications
You must be signed in to change notification settings - Fork 26
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
shadowbas
wants to merge
65
commits into
master
Choose a base branch
from
shadowbas/feat-accessible-table
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 dc9660a
Add support for th and td templating
shadowbas 0cf0898
Finalize drag and drop
shadowbas 4c962cb
Fix height diff between rows
shadowbas 8f72dc8
Fix reactive model of table
shadowbas 70822a1
fixup! Fix reactive model of table
shadowbas b3b794e
fixup! fixup! Fix reactive model of table
shadowbas cb45f95
fixup! fixup! fixup! Fix reactive model of table
shadowbas 45dc036
fixup! fixup! fixup! fixup! Fix reactive model of table
shadowbas 454500a
fixup! fixup! fixup! fixup! fixup! Fix reactive model of table
shadowbas 9a6fb37
fixup! fixup! fixup! fixup! fixup! fixup! Fix reactive model of table
shadowbas 327a026
Fix the ctrl shift and meta key issue
shadowbas 71b8251
fixup! Fix the ctrl shift and meta key issue
shadowbas 543a951
Resize idea and mapOverIndexes craziness
shadowbas b6d4cc3
fixup! Resize idea and mapOverIndexes craziness
shadowbas d4f835a
fixup! fixup! Resize idea and mapOverIndexes craziness
shadowbas 6654099
Add flagged column
shadowbas 8c64924
Use BehaviorSubject to update firstRowHeight
shadowbas 5315542
Enrich rows also when rows change
shadowbas 96be53b
Use SelectionModel and remove checkbox select logic from table
shadowbas 990d5c4
Prevent checkbox toggle after checked is set
shadowbas 38a38e1
Fix smaller screen layout
shadowbas 9dc3b3f
Do not deselect for certain actions. Fix bulk action when no item is …
shadowbas d7fdb16
Revert the directive resizer changes
shadowbas 04fa3ee
Add resizable columns
shadowbas e0fff28
fixup! Add resizable columns
shadowbas fec9854
fixup! fixup! Add resizable columns
shadowbas 4ed0215
fixup! fixup! fixup! Add resizable columns
shadowbas cdb103b
fixup! fixup! fixup! fixup! Add resizable columns
shadowbas 1820eb0
Add some sane column width defaults
shadowbas 3549fe0
Enable ordering of columns on th click
shadowbas 717450a
Reset column width on dblclick
shadowbas aaadbc7
fixup! Reset column width on dblclick
shadowbas 0bb4a81
Show skeleton when scrolling fast
shadowbas 4dcd7cb
fixup! Show skeleton when scrolling fast
shadowbas 8b6bf21
Fix issue where last selected is set to first item on scroll
shadowbas b31886e
Figure out how to reset column widths on switching routes
shadowbas 027e62a
fixup! Figure out how to reset column widths on switching routes
shadowbas 48f341f
Recompute column width on window resize
shadowbas 806c0f0
Fix issues that caused build to fail
shadowbas 814349a
Fix freezing caused by too many row height checks
shadowbas 47d3048
fixup! fixup! Figure out how to reset column widths on switching routes
shadowbas 00c86aa
Small typing changes in app.component.ts helpers
shadowbas d146390
WIP: Fix memory issue and use message display abstraction
shadowbas 7cf600e
Fix date and from columns values
shadowbas 49dc22f
Make row deselect when selected row clicked
shadowbas 400973b
Fix the damn scroll issue finally with trackBy
shadowbas 5012fb7
Improve resize button style
shadowbas 17d6961
Add answered and folder column and fixed message data fn
shadowbas 7a67bba
Disable canvastable dopaint
shadowbas 53b23f4
fixup! Disable canvastable dopaint
shadowbas f42853e
fixup! fixup! Disable canvastable dopaint
shadowbas bfe52c0
fixup! fixup! fixup! Disable canvastable dopaint
shadowbas d8e0fe4
fixup! fixup! fixup! fixup! Disable canvastable dopaint
shadowbas 205a93d
fixup! fixup! fixup! fixup! fixup! Disable canvastable dopaint
shadowbas 2377ad2
fixup! fixup! fixup! fixup! fixup! fixup! Disable canvastable dopaint
shadowbas f1ee521
fixup! fixup! fixup! fixup! fixup! fixup! fixup! Disable canvastable …
shadowbas fac4243
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Disable canva…
shadowbas 0b5b286
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Disabl…
shadowbas 79609ad
Fix build issue
shadowbas 65d7148
fixup! Fix build issue
shadowbas 393d2af
fixup! fixup! Fix build issue
shadowbas 67fd747
fixup! fixup! fixup! Fix build issue
shadowbas 7628984
Scroll selected message into view
shadowbas cb46f0b
Set column px width on user column resize
shadowbas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<cdk-virtual-scroll-viewport [itemSize]="firstRowHeight" class="email-viewport"> | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.