-
Notifications
You must be signed in to change notification settings - Fork 12
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
Bookmark sorting UI follow-up #992
Conversation
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.
I tried this PR out and I saw a timing bug.
How to replicate:
- Locally change apiUrl in frontend/src/static/index.html to "https://api.webstatus.dev" (as mentioned here)
- Open your browser to http://localhost:5555/
- Let the page load up completely
- Click the ordered bookmark
Top CSS Interop Issues
. - I see the
Unable to apply custom sorting to bookmark "Top CSS Interop issues". Defaulting to normal sorting.
message come up quickly. But I see the right results eventually.
I suspect that we attempt custom sorting on the old results loaded in step 2. Custom sorting fails because that list of results does not have the list of results. But then he results from step 4 finally load in and show the right results.
Spent some time digging into it after chatting offline. I think the root of the issue is caused by I narrowed down the problem to this line, this.loadingTask = new Task(. It does some funky stuff and reassigns an old value to |
@KyleJu @jrobbins I feel like the disabling of the sort here is similar to https://github.com/GoogleChrome/webstatus.dev/pull/995/files We should only have one way to disable the sort. This approach allows us to provide a specific message. In 995, we could just toggle it by setting the specific CELL_DEF to unsortable. I wonder if there's a way to join the two. |
Will address the comments after #995 is merged |
f07181e
to
0f525d9
Compare
I couldn't find a great way to join two, but any suggestions are welcome! |
You could modify renderHeaderCell like this: export function renderHeaderCell(
routerLocation: {search: string},
column: ColumnKey,
sortSpec: string,
+ overrideColumnOpitons?: Map<
+ ColumnKey,
+ {title?: string; unsortable?: boolean}
+ >,
): TemplateResult { Then back in render in webstatus-overview-table, you could do something like this: + let options:
+ | Map<ColumnKey, {title?: string; unsortable?: boolean}>
+ | undefined = undefined;
if (this.bookmark !== undefined && this.bookmark?.is_ordered) {
const bookmarkName = this.bookmark.name;
+ options = new Map<ColumnKey, {title?: string; unsortable?: boolean}>();
+ Object.values(ColumnKey).forEach(column => {
+ const value: {title?: string; unsortable?: boolean} = {
+ unsortable: true,
+ };
+ if (column == ColumnKey.Name) value.title = bookmarkName;
+ options?.set(column, value);
+ });
}
...
...
...
return html`
<table class="data-table">
${renderColgroups(columns)}
<thead>
${renderGroupsRow(columns)}
<tr class="header-row">
${columns.map(
col =>
- html`${renderHeaderCell(this.location, col, sortSpec)}`,
+ html`${renderHeaderCell(this.location, col, sortSpec, options)}`,
)}
</tr>
</thead>
<tbody>
${this.renderTableBody(columns)}
</tbody>
</table>
`; You will need to modify renderHeaderCell to use the options if present. Maybe something like this: |
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.
LGTM with one nit. Talked offline with Kyle. He said he will adjust the tests.
A follow-up for #952 (review). The changes include:
override_num_param
to override thenum
parameter. It helps accommodate the front-end sorting in bookmark queries, which should be <25