Model search dropdown bug fix x3
This commit is contained in:
@@ -780,14 +780,7 @@ class ModelManager extends ComfyDialog {
|
|||||||
placeholder: "example: /0/1.5/styles/clothing -.pt",
|
placeholder: "example: /0/1.5/styles/clothing -.pt",
|
||||||
onkeyup: (e) => e.key === "Enter" && this.#modelGridUpdate(),
|
onkeyup: (e) => e.key === "Enter" && this.#modelGridUpdate(),
|
||||||
oninput: () => this.#updateSearchDropdown(),
|
oninput: () => this.#updateSearchDropdown(),
|
||||||
onfocus: () => {
|
onfocus: () => this.#updateSearchDropdown(),
|
||||||
if (searchDropdown.innerHTML === "") {
|
|
||||||
searchDropdown.style.display = "none";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
searchDropdown.style.display = "block";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onblur: () => { searchDropdown.style.display = "none"; },
|
onblur: () => { searchDropdown.style.display = "none"; },
|
||||||
}),
|
}),
|
||||||
searchDropdown,
|
searchDropdown,
|
||||||
@@ -846,8 +839,6 @@ class ModelManager extends ComfyDialog {
|
|||||||
modelGrid.innerHTML = "";
|
modelGrid.innerHTML = "";
|
||||||
const modelGridModels = ModelGrid.generateInnerHtml(modelList, modelType, this.#el.settings);
|
const modelGridModels = ModelGrid.generateInnerHtml(modelList, modelType, this.#el.settings);
|
||||||
modelGrid.append.apply(modelGrid, modelGridModels);
|
modelGrid.append.apply(modelGrid, modelGridModels);
|
||||||
|
|
||||||
this.#updateSearchDropdown(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async #modelGridRefresh() {
|
async #modelGridRefresh() {
|
||||||
@@ -1005,7 +996,7 @@ class ModelManager extends ComfyDialog {
|
|||||||
$: (el) => (this.#el.settings["model-persistent-search"] = el),
|
$: (el) => (this.#el.settings["model-persistent-search"] = el),
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
}),
|
}),
|
||||||
$el("p", ["Search text persistent across model types"]),
|
$el("p", ["Persistent search text across model types"]),
|
||||||
]),
|
]),
|
||||||
$el("div", [
|
$el("div", [
|
||||||
$el("input", {
|
$el("input", {
|
||||||
@@ -1099,54 +1090,52 @@ class ModelManager extends ComfyDialog {
|
|||||||
return [filterIndex0, cwd];
|
return [filterIndex0, cwd];
|
||||||
}
|
}
|
||||||
|
|
||||||
async #updateSearchDropdown(setHidden = false) {
|
async #updateSearchDropdown() {
|
||||||
const modelType = this.#el.modelTypeSelect.value;
|
const modelType = this.#el.modelTypeSelect.value;
|
||||||
const searchDropdown = this.#el.modelDirectorySearchOptions;
|
const searchDropdown = this.#el.modelDirectorySearchOptions;
|
||||||
const filter = this.#el.modelContentFilter.value;
|
const filter = this.#el.modelContentFilter.value;
|
||||||
|
|
||||||
const directories = this.#data.modelDirectories;
|
const directories = this.#data.modelDirectories;
|
||||||
const previousFilter = this.#data.prevousModelFilters[modelType];
|
//const previousFilter = this.#data.prevousModelFilters[modelType];
|
||||||
|
|
||||||
if (previousFilter !== filter) {
|
let options = [];
|
||||||
let options = [];
|
const sep = "/";
|
||||||
const sep = "/";
|
if (filter[0] === sep) {
|
||||||
if (filter[0] === sep) {
|
let initCwd = null;
|
||||||
let initCwd = null;
|
const root = directories[0];
|
||||||
const root = directories[0];
|
const rootChildIndex = root["childIndex"];
|
||||||
const rootChildIndex = root["childIndex"];
|
const rootChildCount = root["childCount"];
|
||||||
const rootChildCount = root["childCount"];
|
for (let i = rootChildIndex; i < rootChildIndex + rootChildCount; i++) {
|
||||||
for (let i = rootChildIndex; i < rootChildIndex + rootChildCount; i++) {
|
const modelDir = directories[i];
|
||||||
const modelDir = directories[i];
|
if (modelDir["name"] === modelType) {
|
||||||
if (modelDir["name"] === modelType) {
|
initCwd = i;
|
||||||
initCwd = i;
|
break;
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
|
const [filterIndex0, cwd] = this.#getFilterDirectory(
|
||||||
|
filter,
|
||||||
|
directories,
|
||||||
|
sep,
|
||||||
|
initCwd
|
||||||
|
);
|
||||||
|
if (cwd !== null) {
|
||||||
|
const lastWord = filter.substring(filterIndex0);
|
||||||
|
const item = directories[cwd];
|
||||||
|
if (item["childIndex"] !== undefined) {
|
||||||
|
const childIndex = item["childIndex"];
|
||||||
|
const childCount = item["childCount"];
|
||||||
|
const items = directories.slice(childIndex, childIndex + childCount);
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
const itemName = items[i]["name"];
|
||||||
|
if (itemName.startsWith(lastWord)) {
|
||||||
|
options.push(itemName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const [filterIndex0, cwd] = this.#getFilterDirectory(
|
else {
|
||||||
filter,
|
const filename = item["name"];
|
||||||
directories,
|
if (filename.startsWith(lastWord)) {
|
||||||
sep,
|
options.push(filename);
|
||||||
initCwd
|
|
||||||
);
|
|
||||||
if (cwd !== null) {
|
|
||||||
const lastWord = filter.substring(filterIndex0);
|
|
||||||
const item = directories[cwd];
|
|
||||||
if (item["childIndex"] !== undefined) {
|
|
||||||
const childIndex = item["childIndex"];
|
|
||||||
const childCount = item["childCount"];
|
|
||||||
const items = directories.slice(childIndex, childIndex + childCount);
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
|
||||||
const itemName = items[i]["name"];
|
|
||||||
if (itemName.startsWith(lastWord)) {
|
|
||||||
options.push(itemName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const filename = item["name"];
|
|
||||||
if (filename.startsWith(lastWord)) {
|
|
||||||
options.push(filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1158,7 +1147,7 @@ class ModelManager extends ComfyDialog {
|
|||||||
});
|
});
|
||||||
searchDropdown.innerHTML = "";
|
searchDropdown.innerHTML = "";
|
||||||
searchDropdown.append.apply(searchDropdown, innerHtml);
|
searchDropdown.append.apply(searchDropdown, innerHtml);
|
||||||
searchDropdown.style.display = setHidden || options.length == 0 ? "none" : "block";
|
searchDropdown.style.display = options.length === 0 ? "none" : "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#data.prevousModelFilters[modelType] = filter;
|
this.#data.prevousModelFilters[modelType] = filter;
|
||||||
|
|||||||
Reference in New Issue
Block a user