Skip to content

Commit

Permalink
fix: fixes highlighting in creature suggester
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Aug 18, 2023
1 parent e7038d1 commit ee5f812
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/tracker/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type InitiativeTracker from "../main";

import App from "./ui/App.svelte";
import type { Creature } from "../utils/creature";
import type { HomebrewCreature } from "index";
import { PLAYER_VIEW_VIEW } from "../utils/constants";
import type PlayerView from "./player-view";

Expand Down Expand Up @@ -58,7 +57,6 @@ export default class TrackerView extends ItemView {
return [];
}


//open player view
playerViewOpened = false;
getExistingPlayerView(): PlayerView | undefined {
Expand Down Expand Up @@ -146,6 +144,7 @@ export class CreatureView extends ItemView {
await this.renderEmbed(creature.getStatblockLink());
} else if (tryStatblockPlugin) {
const statblock = this.plugin.statblocks.render(
//@ts-ignore
creature,
this.statblockEl,
creature.display
Expand Down
9 changes: 5 additions & 4 deletions src/utils/suggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,10 @@ export class SRDMonsterSuggestionModal extends SuggestionModal<
if (item.player) {
setIcon(name, "user");
}
let text = name.createDiv("name-text");
if (!item) {
this.suggester.selectedItem = null;
name.setText(this.emptyStateText);
text.setText(this.emptyStateText);
content.parentElement.addClass("is-selected");
return;
}
Expand All @@ -379,14 +380,14 @@ export class SRDMonsterSuggestionModal extends SuggestionModal<
let match = matches.matches.find((m) => m[0] === i);
if (match) {
let element = matchElements[matches.matches.indexOf(match)];
name.appendChild(element);
name.appendText(item.name.substring(match[0], match[1]));
text.appendChild(element);
element.appendText(item.name.substring(match[0], match[1]));

i += match[1] - match[0] - 1;
continue;
}

name.appendText(item.name[i]);
text.appendText(item.name[i]);
}
content.createDiv({
cls: "suggestion-note",
Expand Down

0 comments on commit ee5f812

Please sign in to comment.