Skip to content

Fix pat-search when providing URL parameters#1539

Merged
petschki merged 2 commits intomasterfrom
fix-search-pattern
Mar 4, 2026
Merged

Fix pat-search when providing URL parameters#1539
petschki merged 2 commits intomasterfrom
fix-search-pattern

Conversation

@petschki
Copy link
Copy Markdown
Member

@petschki petschki commented Mar 3, 2026

  • I signed and returned the Plone Contributor Agreement, and received and accepted an invitation to join a team in the Plone GitHub organization.
  • I verified there aren't any other open pull requests for the same change.
  • I followed the guidelines in Contributing to Plone.
  • I successfully ran code quality checks on my changes locally.
  • I successfully ran tests on my changes locally.
  • If needed, I added new tests for my changes.
  • If needed, I added documentation for my changes.
  • I included a change log entry in my commits.

Closes plone/Products.CMFPlone#3730

Copy link
Copy Markdown
Member

@thet thet left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread src/pat/search/search.js
clearTimeout(timeout);
timeout = setTimeout(search, 200);
};
const searchDelayed = patUtils.debounce(search, 200);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Comment thread src/pat/search/search.js
([key]) => key !== "ajax_load" && !formParams.has(key)
)
);
formParams.forEach((value, key) => params.append(key, value));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I had to look up why the forEach reverses (key, value) here, but it is correct: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/forEach

This is so JavaScript 🙄

Comment thread src/pat/search/search.js
// any key managed by the form to avoid duplicates
const params = new URLSearchParams(
[...new URLSearchParams(window.location.search)].filter(
([key]) => key !== "ajax_load" && !formParams.has(key)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure, why we would exclude ajax_load also...? But I guess you will have your reasons...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But please tell me :)

Copy link
Copy Markdown
Member Author

@petschki petschki Mar 3, 2026

Choose a reason for hiding this comment

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

since we're adding ajax_load to the url here https://github.com/plone/mockup/blob/fix-search-pattern/src/pat/search/search.js#L69-L73 we would get multiple ajax_load on every click if it's not removed here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we could eventually get rid of ajax_load, because of the new auto ajax check (in http headers) in Plone 6.2 ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hm ... the new configuration plone.use_ajax_main_template is False per default ... so lets go with ajax_load here for now.

@petschki petschki force-pushed the fix-search-pattern branch from 2e1dcc5 to 29d903f Compare March 4, 2026 07:42
@petschki petschki merged commit 583af70 into master Mar 4, 2026
3 checks passed
@petschki petschki deleted the fix-search-pattern branch March 4, 2026 07:55
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.

Search page results by Keyword/Subjects don't batch correctly

2 participants