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

Update-JavaScript-for-search-pagination ( Continuation after PR #9224 ) #9941

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

aym-n
Copy link
Contributor

@aym-n aym-n commented Jan 22, 2023

See #9102 – based upon #9224.

@squash-labs
Copy link

squash-labs bot commented Jan 22, 2023

Manage this branch in Squash

Test this branch here: https://aym-nupdate-javascript-for-sea-j48jf.squash.io

@aym-n
Copy link
Contributor Author

aym-n commented Jan 22, 2023

@lb- i was unable to push to PR #9224 so i made a separate PR

@aym-n
Copy link
Contributor Author

aym-n commented Jan 22, 2023

  • clean up the existing code (use proper event listeners, move the code to an external file search.js and solve any large linting issues.
  • we need to rethink the JS solution

@aym-n aym-n changed the title Updated PR#9224 Updated PR #9224 Jan 22, 2023
@aym-n
Copy link
Contributor Author

aym-n commented Jan 22, 2023

@lb- CI backend test is failing and the log output is ./wagtail/admin/forms/account.py:54:68: E741 ambiguous variable name 'l'

@aym-n aym-n changed the title Updated PR #9224 Update-JavaScript-for-search-pagination ( Continuation after PR #9224 ) Jan 22, 2023
@aym-n
Copy link
Contributor Author

aym-n commented Jan 22, 2023

couldn't find out what is causing the UI Tests Error

@lb-
Copy link
Member

lb- commented Jan 23, 2023

I think the failing Axe test is a known issue. #8938

@aym-n
Copy link
Contributor Author

aym-n commented Jan 23, 2023

@lb- Thanks for reviewing my PR!

What can I do to continue contributing to this issue?
you mentioned about reworking the JS Solution for the pagination , can I start working on that? Or there are any other plans for this issue?

@lb-
Copy link
Member

lb- commented Jan 23, 2023

@aym-n this hasn't been reviewed yet, but we will tag it for review. Not sure on next steps at this time but myself or someone else will review and get back to you.

Thank you for taking the time to get this PR together.

Copy link
Member

@thibaudcolas thibaudcolas left a comment

Choose a reason for hiding this comment

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

Thank you for giving this a go @aym-n! Looks like you’ve made a lot of improvements from this previous pull request, but there are still a few dealbreaker issues (see individual comments).

I think it’s also problematic we’re now combining the separate "search" and "pagination" code all in the same file. The pagination code wasn’t designed to be imported on all pages of the site, so I think it would need even bigger refactorings for that to work.

Perhaps we should rename search.js to pagination.js, keep the layout.html template as-is, and load this pagination.js on the search.html template only?

* See https://github.com/algolia/docsearch-configs/blob/master/configs/wagtail.json for index configuration.
*/
function docSearchReady() {
try {
Copy link
Member

Choose a reason for hiding this comment

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

The fact we now have to wrap this code in a try…catch looks like an anti-pattern to me. Can we deal with the errors that are arising here another way?

// Display pagination if more than 1 page returned
const { nbPages } = result;
if (nbPages > 1) {
document.querySelector('#pagination').hidden = false;
Copy link
Member

Choose a reason for hiding this comment

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

This can’t work because we’ve removed id="pagination" from that element. There’s lots of other code below which also relies on this id, so I’d assume the pagination is completely broken as-is.

for (let i = start; i < end; i += 1) {
const newPaginationItem = document.createElement('li');
const newPaginationbutton = document.createElement('button');
newPaginationbutton.classList.add('pagination-button');
Copy link
Member

Choose a reason for hiding this comment

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

This button isn’t styled correctly in our dark theme for the documentation.

@thibaudcolas thibaudcolas removed the request for review from lb- February 17, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants