Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ function initSearchUI() {
if (urlParams.sort) {
params.sort = urlParams.sort;
}
// set the custom action cause for the initial search
if ( urlParams.actionCause ) {
params.actionCause = urlParams.actionCause;

// changing the URL without reloading the page to remove actionCause
if ( window.history.pushState ) {
var newurl = winLoc.href.replace( '&actionCause=' + urlParams.actionCause, '' );
Copy link
Contributor

Choose a reason for hiding this comment

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

You should use params.actionCause on this line

window.history.pushState( { path : newurl }, '', newurl );
Copy link
Contributor

Choose a reason for hiding this comment

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

During our next technical touchpoint with GC Search team, let's make it an item to consider and test this in case of edge cases such as other parameters used; I'm thinking Canadian Food Guide (https://food-guide.canada.ca/en/), as well as Canada Gazette (https://gazette.gc.ca/accueil-home-eng.html).

}
}

// Auto detect relative path from originLevel3
if( !params.originLevel3.startsWith( "/" ) && /http|www/.test( params.originLevel3 ) ) {
Expand Down Expand Up @@ -585,6 +595,12 @@ function initEngine() {
// filter user sensitive content
requestContent.originLevel3 = params.originLevel3;

// override actionCause if present
if ( params.actionCause ) {
requestContent.actionCause = params.actionCause;
params.actionCause = ""; // reset the parameter to avoid polluting future searches with the same action cause
}

// documentAuthor cannot be longer than 128 chars based on search platform
if ( requestContent.documentAuthor ) {
requestContent.documentAuthor = requestContent.documentAuthor.substring( 0, 128 );
Expand Down Expand Up @@ -612,6 +628,11 @@ function initEngine() {
requestContent.analytics.originLevel3 = params.originLevel3;
}

// override actionCause if present
if ( params.actionCause ) {
requestContent.analytics.actionCause = params.actionCause;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't you need to clear params.actionClause it here as well?

}

let q = requestContent.q;
requestContent.q = sanitizeQuery( q );

Expand Down
52 changes: 52 additions & 0 deletions src/suggestions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Search UI: Styles for Query suggestion List "combobox", TO BE eventually replaced by GCWeb reference implementation codebase
*/
.query-suggestions {
background-color: white;
border-bottom: 1px solid #ccc;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this line since the style will apply from line 44 in this file instead. And please ensure the border color is consistent.

border-left: 1px solid #e0e0e0;
border-right: 1px solid #e0e0e0;
width: calc(100% - 30px);
cursor: pointer;
list-style-type: none;
padding: 0;
position: absolute;
z-index: 60;
}

.query-suggestions li {
padding: 5px 10px 5px 30px;
position: relative;
}

.query-suggestions li:hover {
background-color: #ddd;
}

.query-suggestions .suggestion-item::before {
content: "\e003";
font-family: "Glyphicons Halflings";
font-size: 0.8em;
line-height: 1.4;
margin-right: 12px;
position: relative;
top: 1px;
position: absolute;
transform: translateY(50%);
left: 8px;
}

.query-suggestions .selected-suggestion {
background-color: #ddd;
}

.query-suggestions:has(li) {
border-bottom: 1px solid #ccc;
}

@media screen and (max-width: 991px) {
.query-suggestions {
position: relative;
width: 100%;
}
}
Loading