Skip to content

Commit 262069e

Browse files
committed
Revise New and Edit search buttons (#386)
Two things: First, clear sessionStorage before sending to search form, thus fixing a bug in the implementation. Second, clear query string when search form is reloaded similar to sessionStorage (#481). Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
1 parent 6244cd1 commit 262069e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

public/js/search.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ $.webshims.polyfill('forms');
1212
*/
1313
if (performance.navigation.type == performance.navigation.TYPE_RELOAD) {
1414
sessionStorage.clear();
15+
history.replaceState(null, '', location.href.split('?')[0]);
1516
}
1617

1718
var Page = React.createClass({

public/js/sidebar.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ import AlignmentExporter from './alignment_exporter'; // to download textual ali
99
* Renders links for navigating to each query.
1010
*/
1111
export default React.createClass({
12+
/**
13+
* Clear sessionStorage - useful to initiate a new search in the same tab.
14+
* Passing sessionStorage.clear directly as onclick callback didn't work
15+
* (on macOS Chrome).
16+
*/
17+
clearSession: function () {
18+
sessionStorage.clear();
19+
},
20+
1221
/**
1322
* Event-handler for downloading fasta of all hits.
1423
*/
@@ -92,8 +101,11 @@ export default React.createClass({
92101

93102
topPanelJSX: function () {
94103
var path = location.pathname.split('/');
104+
// Get job id.
95105
var job_id = path.pop();
96-
path = path.join('/');
106+
// Deriving rootURL this way is required for subURI deployments
107+
// - we cannot just send to '/'.
108+
var rootURL = path.join('/');
97109

98110
return (
99111
<div className="sidebar-top-panel">
@@ -103,11 +115,12 @@ export default React.createClass({
103115
</h4>
104116
</div>
105117
<div>
106-
<a href={`${path}/?job_id=${job_id}`}>
118+
<a href={`${rootURL}/?job_id=${job_id}`}>
107119
<i className="fa fa-pencil"></i> Edit search
108120
</a>
109121
<span className="line">|</span>
110-
<a href={`${path}/`}>
122+
<a href={`${rootURL}/`}
123+
onClick={this.clearSession}>
111124
<i className="fa fa-file-o"></i> New search
112125
</a>
113126
</div>

0 commit comments

Comments
 (0)