Rework reasoning CSS selectors and fixes

- Remove reliance on :empty state of reasoning textbox, now using the actual css class on mes (".mes.reasoning")
- Fix reasoning add not working when Auto-Expand is not enabled
- Clean setting of dataset attributes, now removing when null
This commit is contained in:
Wolfsblvt
2025-02-11 21:45:54 +01:00
parent d60609716b
commit 21af0243d6
3 changed files with 34 additions and 17 deletions

View File

@ -2059,6 +2059,23 @@ export function toggleDrawer(drawer, expand = true) {
}
}
/**
* Sets or removes a dataset property on an HTMLElement
*
* Utility function to make it easier to reset dataset properties on null, without them being "null" as value.
*
* @param {HTMLElement} element - The element to modify
* @param {string} name - The name of the dataset property
* @param {string|null} value - The value to set - If null, the dataset property will be removed
*/
export function setDatasetProperty(element, name, value) {
if (value === null) {
delete element.dataset[name];
} else {
element.dataset[name] = value;
}
}
export async function fetchFaFile(name) {
const style = document.createElement('style');
style.innerHTML = await (await fetch(`/css/${name}`)).text();