Skip to content

Commit d8572f1

Browse files
authored
Fix .tsmb-icon-close to not rely on inline style attribute
This makes the web component compatible with a stict CSP setting, without granting `style-src unsafe-inline`, and without hardcoding a hash of the exact `display: none;` value.
1 parent 865654e commit d8572f1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

typesense-minibar.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ typesense-minibar form::before {
117117
cursor: pointer;
118118
}
119119

120-
.tsmb-form--open .tsmb-icon-close {
121-
display: block !important;
120+
form:not(.tsmb-form--open) .tsmb-icon-close {
121+
display: none;
122122
}
123123

124124
.tsmb-form--slash:not(.tsmb-form--open):not(:focus-within)::after {

typesense-minibar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
7474
form.addEventListener('submit', function (e) {
7575
e.preventDefault();
7676
});
77-
form.insertAdjacentHTML('beforeend', '<svg viewBox="0 0 12 12" width="20" height="20" aria-hidden="true" tabindex="-1" 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>');
7878
form.querySelector('.tsmb-icon-close').addEventListener('click', function () {
7979
input.value = '';
8080
state.hits = [];

0 commit comments

Comments
 (0)