Skip to content

Commit 6aa2a97

Browse files
authored
Fix the flutter SDK search box loading on non-root pages with --use-base-href (#2158)
* Fix flutter search box * Refine comment
1 parent c535249 commit 6aa2a97

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/resources/script.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ function initSearch(name) {
100100
'constructor' : 4
101101
};
102102

103-
var baseHref = $('body').data('base-href');
103+
var baseHref = '';
104+
if (!$('body').data('using-base-href')) {
105+
// If dartdoc did not add a base-href tag, we will need to add the relative
106+
// path ourselves.
107+
baseHref = $('body').data('base-href');
108+
}
104109

105110
function findMatches(q) {
106111
var allMatches = []; // list of matches

lib/templates/html/_head.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
</head>
3232

3333
{{! We don't use <base href>, but we do lookup the htmlBase from javascript. }}
34-
<body data-base-href="{{{htmlBase}}}">
34+
<body data-base-href="{{{htmlBase}}}"
35+
data-using-base-href="{{{useBaseHref}}}">
3536

3637
<div id="overlay-under-drawer"></div>
3738

0 commit comments

Comments
 (0)