mirror of
https://github.com/decaf-dev/obsidian-vault-explorer.git
synced 2026-07-22 10:10:31 +00:00
fix: save and display value
This commit is contained in:
parent
d4d25a74f4
commit
21ed53af78
2 changed files with 16 additions and 13 deletions
|
|
@ -108,8 +108,8 @@
|
|||
};
|
||||
});
|
||||
|
||||
function handleValueChange(e: Event) {
|
||||
const value = (e.target as HTMLInputElement).value;
|
||||
function handleValueChange(e: CustomEvent) {
|
||||
const { value } = e.detail;
|
||||
dispatch("ruleValueChange", { id, value });
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +135,7 @@
|
|||
on:ruleToggle
|
||||
>
|
||||
<svelte:fragment slot="after-condition">
|
||||
<SearchSelect options={folders} />
|
||||
<SearchSelect {value} options={folders} on:select={handleValueChange} />
|
||||
<input
|
||||
aria-label="Include subfolders"
|
||||
type="checkbox"
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import Icon from "./icon.svelte";
|
||||
|
||||
export let width = "fit-content";
|
||||
export let options: string[] = [];
|
||||
export let value: string = "";
|
||||
|
||||
let inputValue = "";
|
||||
let selectedValue = "";
|
||||
let inputValue = value;
|
||||
let isOpen = false;
|
||||
let dropdownRef: HTMLDivElement | null = null;
|
||||
let currentFocusIndex = 0;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
onMount(() => {
|
||||
document.addEventListener("click", handleClickOutside);
|
||||
|
||||
|
|
@ -30,10 +32,11 @@
|
|||
currentFocusIndex = 0;
|
||||
}
|
||||
|
||||
function handleOptionClick(e: Event, option: string) {
|
||||
function handleOptionClick(option: string) {
|
||||
inputValue = option;
|
||||
selectedValue = option;
|
||||
value = option;
|
||||
isOpen = false;
|
||||
dispatch("select", { value: option });
|
||||
}
|
||||
|
||||
function handleInputChange(e: Event) {
|
||||
|
|
@ -70,7 +73,7 @@
|
|||
if (isOpen) {
|
||||
const option = filteredOptions[currentFocusIndex];
|
||||
if (option) {
|
||||
handleOptionClick(e, option);
|
||||
handleOptionClick(option);
|
||||
}
|
||||
} else {
|
||||
openDropdown();
|
||||
|
|
@ -100,7 +103,7 @@
|
|||
<div class="vault-explorer-search-selection" style={`width: ${width}`}>
|
||||
<input
|
||||
bind:value={inputValue}
|
||||
placeholder={selectedValue || "Search..."}
|
||||
placeholder={value || "Search..."}
|
||||
type="text"
|
||||
on:input={handleInputChange}
|
||||
on:focus={handleInputFocus}
|
||||
|
|
@ -116,12 +119,12 @@
|
|||
<div
|
||||
tabindex="-1"
|
||||
role="option"
|
||||
aria-selected={option === selectedValue}
|
||||
aria-selected={option === value}
|
||||
class="vault-explorer-dropdown-item"
|
||||
class:vault-explorer-dropdown-item--selected={currentFocusIndex ===
|
||||
i}
|
||||
on:click={(e) => handleOptionClick(e, option)}
|
||||
on:keydown={(e) => {}}
|
||||
on:click={() => handleOptionClick(option)}
|
||||
on:keydown={() => {}}
|
||||
>
|
||||
{option}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue