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

Unescape search result page title and set via textContent #9965

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jimchamp
Copy link
Collaborator

Closes #9787

Unescapes the search result title, then updates the title via the title element's textContent property.

Technical

Testing

Screenshot

Stakeholders

@jimchamp jimchamp changed the title Unescape search result title and set via textContent Unescape search result page title and set via textContent Oct 28, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 17.11%. Comparing base (ce16a79) to head (3bd171d).
Report is 491 commits behind head on master.

Files with missing lines Patch % Lines
openlibrary/plugins/openlibrary/js/search.js 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9965      +/-   ##
==========================================
+ Coverage   16.06%   17.11%   +1.05%     
==========================================
  Files          90       89       -1     
  Lines        4769     4755      -14     
  Branches      832      831       -1     
==========================================
+ Hits          766      814      +48     
+ Misses       3480     3431      -49     
+ Partials      523      510      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -78,7 +80,7 @@ export function initSearchFacets(facetsElem) {
facetsElem.replaceWith(newFacetsElem)
hydrateFacets()

document.title = data.title
setTitle(data.title)
Copy link
Collaborator

@cdrini cdrini Nov 4, 2024

Choose a reason for hiding this comment

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

Can we avoid html-escaping the title entirely on the python side, where data is created? Then we can do document.title = data.title, and avoid the lodash dependency.

@@ -88,6 +90,10 @@ export function initSearchFacets(facetsElem) {
}
}

function setTitle(title) {
const titleElem = document.querySelector('title')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think modifying document.title is more idiomatic for change the title; was there a reason you switch to querySelector?

@cdrini cdrini added Priority: 2 Important, as time permits. [managed] Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] Priority: 2 Important, as time permits. [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect HTML Entity Displayed in Browser Tab Title for Search Query
3 participants