Skip to content

Commit 9960ace

Browse files
committed
All: Update typesense-minibar to 1.3.4 (CSP compliance)
Ref jquery/infrastructure-puppet#54. Ref #463.
1 parent 799f789 commit 9960ace

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"scripts": {
99
"test": "parallel-lint --exclude vendor/ .",
1010
"deps": [
11-
"curl -O -q --output-dir themes/jquery/lib/typesense-minibar 'https://raw.githubusercontent.com/jquery/typesense-minibar/1.3.2/{typesense-minibar.css,typesense-minibar.js,LICENSE.txt}'",
12-
"curl -q https://raw.githubusercontent.com/jquery/typesense-minibar/1.3.2/typesense-minibar-foot.css >> themes/jquery/lib/typesense-minibar/typesense-minibar.css",
11+
"curl -O -q --output-dir themes/jquery/lib/typesense-minibar 'https://raw.githubusercontent.com/jquery/typesense-minibar/1.3.4/{typesense-minibar.css,typesense-minibar.js,LICENSE.txt}'",
12+
"curl -q https://raw.githubusercontent.com/jquery/typesense-minibar/1.3.4/typesense-minibar-foot.css >> themes/jquery/lib/typesense-minibar/typesense-minibar.css",
1313
"curl -O -q --output-dir plugins/memcached 'https://raw.githubusercontent.com/Automattic/wp-memcached/35e1ea16f6b8cb8a1e6fbca124e33a44db21fa74/{object-cache.php,readme.txt,LICENSE}'"
1414
]
1515
}

themes/jquery/header.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<meta name="viewport" content="width=device-width">
1919

2020
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/i/favicon.ico">
21-
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/lib/typesense-minibar/typesense-minibar.css?v=1.3.2">
21+
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/lib/typesense-minibar/typesense-minibar.css?v=1.3.4">
2222
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/base.css?v=17">
2323
<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>?v=8">
2424

@@ -27,7 +27,7 @@
2727
<?php
2828
if ( jq_search_get_provider() === 'typesense' ) :
2929
?>
30-
<script defer type="module" src="<?php echo get_template_directory_uri(); ?>/lib/typesense-minibar/typesense-minibar.js?v=1.3.2"></script>
30+
<script defer type="module" src="<?php echo get_template_directory_uri(); ?>/lib/typesense-minibar/typesense-minibar.js?v=1.3.4"></script>
3131
<?php
3232
endif;
3333

themes/jquery/lib/typesense-minibar/typesense-minibar.css

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! https://github.com/jquery/typesense-minibar 1.3.2 */
1+
/*! https://github.com/jquery/typesense-minibar 1.3.4 */
22
.tsmb-form,
33
typesense-minibar {
44
--tsmb-size-edge: 1px;
@@ -24,6 +24,8 @@ typesense-minibar {
2424
--tsmb-color-primary30: #390f39;
2525
--tsmb-color-primary50: #9c3493;
2626
--tsmb-color-primary90: #fbdbfb;
27+
28+
max-width: 100%;
2729
}
2830

2931
.tsmb-form,
@@ -88,7 +90,7 @@ typesense-minibar form::before {
8890
content: '';
8991
background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='654 -372 1664 1664' width='20' height='20'><path d='M1806,332c0-123.3-43.8-228.8-131.5-316.5C1586.8-72.2,1481.3-116,1358-116s-228.8,43.8-316.5,131.5 C953.8,103.2,910,208.7,910,332s43.8,228.8,131.5,316.5C1129.2,736.2,1234.7,780,1358,780s228.8-43.8,316.5-131.5 C1762.2,560.8,1806,455.3,1806,332z M2318,1164c0,34.7-12.7,64.7-38,90s-55.3,38-90,38c-36,0-66-12.7-90-38l-343-342 c-119.3,82.7-252.3,124-399,124c-95.3,0-186.5-18.5-273.5-55.5s-162-87-225-150s-113-138-150-225S654,427.3,654,332 s18.5-186.5,55.5-273.5s87-162,150-225s138-113,225-150S1262.7-372,1358-372s186.5,18.5,273.5,55.5s162,87,225,150s113,138,150,225 S2062,236.7,2062,332c0,146.7-41.3,279.7-124,399l343,343C2305.7,1098.7,2318,1128.7,2318,1164z'/></svg>") 0 50% / contain no-repeat;
9092
position: absolute;
91-
top: calc(var(--tsmb-size-sm) + var(--tsmb-size-edge));
93+
top: calc(var(--tsmb-size-edge) + var(--tsmb-size-sm));
9294
left: var(--tsmb-size-sm);
9395
width: var(--tsmb-size-base);
9496
height: var(--tsmb-size-input);
@@ -104,7 +106,7 @@ typesense-minibar form::before {
104106
.tsmb-icon-close {
105107
box-sizing: border-box;
106108
position: absolute;
107-
top: calc(50% - var(--tsmb-size-base)/2);
109+
top: calc(var(--tsmb-size-edge) + var(--tsmb-size-sm) + (var(--tsmb-size-input)/2) - (var(--tsmb-size-base)/2));
108110
right: var(--tsmb-size-base);
109111
width: var(--tsmb-size-base);
110112
height: var(--tsmb-size-base);
@@ -115,11 +117,7 @@ typesense-minibar form::before {
115117
cursor: pointer;
116118
}
117119

118-
.tsmb-form--open .tsmb-icon-close {
119-
display: block !important;
120-
}
121-
122-
.tsmb-form--slash::after {
120+
form:not(.tsmb-form--open) .tsmb-icon-close {
123121
display: none;
124122
}
125123

@@ -245,7 +243,7 @@ typesense-minibar[data-group=true] .tsmb-suggestion_title {
245243
content: ' Typesense';
246244
color: #0300b0;
247245
}
248-
/*! https://github.com/jquery/typesense-minibar 1.3.2 */
246+
/*! https://github.com/jquery/typesense-minibar 1.3.4 */
249247
.tsmb-foot::after {
250248
content: "";
251249
display: inline-block;

themes/jquery/lib/typesense-minibar/typesense-minibar.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! https://github.com/jquery/typesense-minibar 1.3.2 */
1+
/*! https://github.com/jquery/typesense-minibar 1.3.4 */
22
globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
33
const cache = new Map();
44
const state = { query: '', cursor: -1, open: false, hits: [] };
@@ -41,7 +41,6 @@ globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
4141
const query = state.query = input.value;
4242
if (!query) {
4343
state.hits = [];
44-
state.cursor = -1;
4544
return close();
4645
}
4746
const hits = await search(query);
@@ -62,7 +61,10 @@ globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
6261
if (!e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
6362
if (e.code === 'ArrowDown') moveCursor(1);
6463
if (e.code === 'ArrowUp') moveCursor(-1);
65-
if (e.code === 'Escape') close();
64+
if (e.code === 'Escape') {
65+
close();
66+
input.blur();
67+
}
6668
if (e.code === 'Enter') {
6769
const url = state.hits[state.cursor]?.url;
6870
if (url) location.href = url;
@@ -72,11 +74,12 @@ globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
7274
form.addEventListener('submit', function (e) {
7375
e.preventDefault();
7476
});
75-
form.insertAdjacentHTML('beforeend', '<svg viewBox="0 0 12 12" width="20" height="20" aria-hidden="true" class="tsmb-icon-close" style="display: none;"><path d="M9 3L3 9M3 3L9 9"/></svg>');
77+
form.insertAdjacentHTML('beforeend', '<svg viewBox="0 0 12 12" width="20" height="20" aria-hidden="true" tabindex="-1" class="tsmb-icon-close"><path d="M9 3L3 9M3 3L9 9"/></svg>');
7678
form.querySelector('.tsmb-icon-close').addEventListener('click', function () {
7779
input.value = '';
78-
input.focus();
80+
state.hits = [];
7981
close();
82+
input.focus();
8083
});
8184
connect();
8285

@@ -117,7 +120,7 @@ globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
117120
let hits = cache.get(query);
118121
if (hits) {
119122
cache.delete(query);
120-
cache.set(query, hits); // LRU
123+
cache.set(query, hits);
121124
return hits;
122125
}
123126
searchParams.set('q', query);

0 commit comments

Comments
 (0)