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 62 commits into
base: master
Choose a base branch
from

Conversation

shadowbas
Copy link
Contributor

@shadowbas shadowbas commented Nov 29, 2024

Add table to the app component.

  • Render massive amounts of data (tested with a million records)
  • Advanced (range) select features
  • Keyboard friendly with Tab and Enter.
  • Toggle preview with UI button
  • Use arrow keys to move up and down a message.
  • Use j and k to scroll up and down in messages. Dropped the support for j and k scroll.
  • Allow passing templates to render the cells (allows for more rich components).
  • Make the canvastable inert and not actually render to screen.
  • Drag and drop to folders.
  • Bulk actions on selected items.
  • Select row when navigating on fragment.
  • Show to in sent folder instead of from
  • Remove canvastable code as much as possible.
  • Add the flag icon on flagged messages.
  • Add aria-label to attachment icon.
  • Add aria-label to flagged messages.
  • Autosquash and force push.
  • Fix issue where ctrl+tab causes ctrl flag to stay true.
  • Better styling for narrow screen (break out of the table layout by using different display, considering flex)
  • Should only get the doc data when the item is in view (causing massive amount of requests)
  • Resize-able columns.
  • Fix the width of columns on initial render. This prevents jumping of columns during scroll.
  • Set sane defaults for initial columns widths.
  • Sort on column heading click.
  • Would be nice to have a sticky table head
  • Fix to table when index-sync-off in sent folder
  • Double click on column resize separator resets width
  • Figure out how to reset column widths on switching routes
  • Fix bug where last selected item is removed when no longer in view (selects first item)
  • Remove console. calls
  • Could we add a more visible/intuitive column divider indicator in the column header?
  • There doesn't seem to be a folder column in search results, which would be useful to have.
  • Fix issue where new rows causes weird scroll jump upward
  • Add answered column
  • Fix issue where columns are very narrow on initial load

@shadowbas shadowbas force-pushed the shadowbas/feat-accessible-table branch from 596aec9 to 972eb6a Compare December 5, 2024 14:08
canvastablecontainer {
opacity: 0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would be better to instead get rid of anything canvas related in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Remove this.canv and the canvas element from canvastable

@@ -68,3 +72,10 @@
width: 150px;
}

.text-primary {
color: #01579b;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move to a css property

return Array.from(this.selectedRows).map(x => x.id);
}

updateRows() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where I normalize the sync messages and non-sync messages. It's a mess but the simplest I could thing of

this.rows = (() => {
if (!this.canvastable?.rows?.rows?.length) return []

if (Array.isArray(this.canvastable.rows.rows[0]))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for when the rows are the arrays where the first item is the messageid.

@castaway
Copy link
Contributor

castaway commented Dec 9, 2024

Initial thoughts

  • I'd like to keep the abstraction for the messagedisplay and column lists - for column lists especially we have a plan to allow users to rearrange them, so they should ideally not be defined in the template - canvastable is the only place messagedisplay is used, so it can be improved if needed for this feature
  • messagedisplay for example already has the ability to return selectedMessageIds for each possible type of display, so I don't think it makes sense to redo that (confusingly ;)
  • there's still a fair amount of this.canvastable.rows references in app.component.ts that presumably still need changing

@shadowbas shadowbas requested a review from gtandersen December 12, 2024 12:10
async enrichRows() {
const { start, end } = this.renderedRange

this.rows = await Promise.all(mapOverIndexes(async (value) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might cause a race condition. When renderedRange changes twice; it might happen that the first range change resolves later than the second range change.

  • Find a way to merge resolved arrays in a way that will keep the latest and not overwrite fetched rows

@@ -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

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

<td class="checkbox-cell">
<mat-checkbox
(click)="onCheckboxClick($event, item, index)"
[checked]="rowsSelectionModel.isSelected(item)"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Remove event listener from the skeleton version of a row.

(sortToggled)="updateSearch(true)">
</canvastablecontainer>

<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.

@castaway , at some point I think it makes sense to move this table definition into its own component.

I believe that time to be when we want to re-use this table in other places either because we want to have better routing for folders or for some other reason that requires re-use.


}

.skeleton-bone {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move skeleton styles to global styles.


const result = (value / Math.pow(base, exponent)).toFixed(decimalPlaces);
return `${parseFloat(result)} ${suffixes[exponent]}`;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It appears we have a function in src/app/messagetable/messagetablerow.ts. The converting of a number that represents the amount of bytes to a human readable format is not specific to messagetable.

  • Make a human-readable utility module and use that here and in the messagetablerow.ts.

const selection = (this.selectionModel.isMultipleSelection() ? items : [items]) as T[];
this.selectionModel.setSelection(...selection)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Angular allows for two way binding in the template. Here we wrap the angular Selection model and add the selected property to be used for binding.

}
});
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A SelectionModel that takes a predicate which is used to filter items selected using the .select(...items) method. This is handy to prevent selecting items that have not been loaded yet. This is relevant when doing a range select which contains items that have not been loaded into array yet.

@HostListener('window:resize')
onWindowResize() {
this.resetWidth();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be here? When do we want to reset the widths?

size: this.getRow(rowIndex).size,
};
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@castaway , could you please help with how to test the websocketsearchmaillist?

} catch (e) {
// This shouldnt happen, it means something changed the stored
// data without updating the messagedisplay rows.
console.log('Tried to lookup ' + index + ' in searchIndex, isnt there! ' + e);
console.error('Tried to lookup ' + index + ' in searchIndex, isnt there! ' + e);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Change + e to , e for more useful log in console

seen: this.searchService.getDocData(this.getRowId(index)).seen,
};

if (app.viewmode === 'conversations') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Add the conversation count also to the accessible table as it was in canvastable.

// console.log(`${f}`);
// console.log(FS.stat(`${this.partitionsdir}/${f}`));
});
// });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the look as it does nothing but block the thread. Easy performance win

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants