Skip to content

Commit

Permalink
Fixed bug when search result is inside description of external post (a…
Browse files Browse the repository at this point in the history
…lshedivat#2710)

Fixed a very specific bug that was happening when, for example,
searching for the word `round`, which caused this:


![image](https://github.com/user-attachments/assets/d6009462-ae03-4bc2-9ee3-60cb16dce20c)

After a lot of debugging I found out that the search result was in the
svg icon definition. Finally got to fix this.


![image](https://github.com/user-attachments/assets/cc179ea1-e9b8-4695-b98a-adf1472ecca5)

Signed-off-by: George Araújo <[email protected]>
  • Loading branch information
george-gca committed Sep 20, 2024
1 parent daa402f commit fdaed74
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/js/search/ninja-action.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
var __decorate=this&&this.__decorate||function(t,e,i,n){var o,a=arguments.length,s=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(a<3?o(s):a>3?o(e,i,s):o(e,i))||s);return a>3&&s&&Object.defineProperty(e,i,s),s};import{LitElement,html,css}from"./lit/index.min.js";import{customElement,property}from"./lit/decorators.min.js";import{classMap}from"./lit/directives/class-map.min.js";import{unsafeHTML}from"./lit/directives/unsafe-html.min.js";import{join}from"./lit/directives/join.min.js";let NinjaAction=class extends LitElement{constructor(){super(),this.selected=!1,this.hotKeysJoinedView=!0,this.addEventListener("click",this.click)}ensureInView(){this.scrollIntoView({block:"nearest"})}click(){this.dispatchEvent(new CustomEvent("actionsSelected",{detail:this.action,bubbles:!0,composed:!0}))}updated(t){t.has("selected")&&this.selected&&this.ensureInView()}highlightMatch(t,e){let i="",n=0;for(let o=0;o<t.length;o++)e[n]===o?(i+=`<span class="highlight">${t[o]}</span>`,n++):i+=t[o];return unsafeHTML(i)}render(){let t,e;this.action.mdIcon?t=html`<div>${this.action.mdIcon}</div>`:this.action.icon&&(t=this.action.icon?unsafeHTML(`<div class="ninja-icon">${this.action.icon}</div>`):""),this.action.hotkey&&(e=this.hotKeysJoinedView?this.action.hotkey.split(",").map((t=>{const e=t.split("+"),i=html`${join(e.map((t=>html`<kbd>${t}</kbd>`)),"+")}`;return html`<div class="ninja-hotkey ninja-hotkeys">${i}</div>`})):this.action.hotkey.split(",").map((t=>{const e=t.split("+").map((t=>html`<kbd class="ninja-hotkey">${t}</kbd>`));return html`<kbd class="ninja-hotkeys">${e}</kbd>`})));const i={selected:this.selected,"ninja-action":!0};return html`
var __decorate=this&&this.__decorate||function(t,e,i,n){var o,a=arguments.length,s=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(a<3?o(s):a>3?o(e,i,s):o(e,i))||s);return a>3&&s&&Object.defineProperty(e,i,s),s};import{LitElement,html,css}from"./lit/index.min.js";import{customElement,property}from"./lit/decorators.min.js";import{classMap}from"./lit/directives/class-map.min.js";import{unsafeHTML}from"./lit/directives/unsafe-html.min.js";import{join}from"./lit/directives/join.min.js";let NinjaAction=class extends LitElement{constructor(){super(),this.selected=!1,this.hotKeysJoinedView=!0,this.addEventListener("click",this.click)}ensureInView(){this.scrollIntoView({block:"nearest"})}click(){this.dispatchEvent(new CustomEvent("actionsSelected",{detail:this.action,bubbles:!0,composed:!0}))}updated(t){t.has("selected")&&this.selected&&this.ensureInView()}highlightMatch(t,e){const tt=new DOMParser().parseFromString(t,'text/html').body.textContent||"";let i="",n=0,o=0;for(o=0;o<tt.length;o++)e[n]===o?(i+=`<span class="highlight">${t[o]}</span>`,n++):i+=t[o];if(o<t.length){i+=t.slice(o);}return unsafeHTML(i)}render(){let t,e;this.action.mdIcon?t=html`<div>${this.action.mdIcon}</div>`:this.action.icon&&(t=this.action.icon?unsafeHTML(`<div class="ninja-icon">${this.action.icon}</div>`):""),this.action.hotkey&&(e=this.hotKeysJoinedView?this.action.hotkey.split(",").map((t=>{const e=t.split("+"),i=html`${join(e.map((t=>html`<kbd>${t}</kbd>`)),"+")}`;return html`<div class="ninja-hotkey ninja-hotkeys">${i}</div>`})):this.action.hotkey.split(",").map((t=>{const e=t.split("+").map((t=>html`<kbd class="ninja-hotkey">${t}</kbd>`));return html`<kbd class="ninja-hotkeys">${e}</kbd>`})));const i={selected:this.selected,"ninja-action":!0};return html`
<div class="ninja-action" part="ninja-action ${this.selected?"ninja-selected":""}" class=${classMap(i)}>
${t}
${this.action.type?html`<div class="ninja-action-type" style="background: ${n=this.action.type,"debug"===n?"#034900":"general"===n?"#193C79":"segments"===n?"#2F0A7D":"#000000"}">
Expand Down
2 changes: 1 addition & 1 deletion assets/js/search/ninja-keys.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fdaed74

Please sign in to comment.