Skip to content

Commit

Permalink
Fix .tsmb-icon-close to not rely on inline style attribute
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Krinkle committed Aug 22, 2024
1 parent 865654e commit 54afc52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions typesense-minibar.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ typesense-minibar form::before {
cursor: pointer;
}

.tsmb-form--open .tsmb-icon-close {
display: block !important;
form:not(.tsmb-form--open) .tsmb-icon-close {
display: none;
}

.tsmb-form--slash:not(.tsmb-form--open):not(:focus-within)::after {
Expand Down
2 changes: 1 addition & 1 deletion typesense-minibar.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ globalThis.tsminibar = function tsminibar (form, dataset = form.dataset) {
form.addEventListener('submit', function (e) {
e.preventDefault();
});
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>');
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>');
form.querySelector('.tsmb-icon-close').addEventListener('click', function () {
input.value = '';
state.hits = [];
Expand Down

0 comments on commit 54afc52

Please sign in to comment.