diff --git a/public/script.js b/public/script.js index c501c437e..6e25210ff 100644 --- a/public/script.js +++ b/public/script.js @@ -10577,9 +10577,6 @@ jQuery(async function () { stopScriptExecution(); }); - const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/'); - const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx)); - $('.drawer-toggle').on('click', function () { var icon = $(this).find('.drawer-icon'); var drawer = $(this).parent().find('.drawer-content'); @@ -10619,8 +10616,7 @@ jQuery(async function () { } // Set the height of "autoSetHeight" textareas within the drawer to their scroll height - - if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + if (!CSS.supports('field-sizing', 'content')) { $(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () { await resetScrollHeight($(this)); return; @@ -10697,7 +10693,7 @@ jQuery(async function () { $(this).closest('.inline-drawer').find('.inline-drawer-content').stop().slideToggle(); // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height - if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + if (!CSS.supports('field-sizing', 'content')) { $(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () { await resetScrollHeight($(this)); return; diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js index 83f0d0a99..82772a8bd 100644 --- a/public/scripts/group-chats.js +++ b/public/scripts/group-chats.js @@ -1491,9 +1491,11 @@ function select_group_chats(groupId, skipAnimation) { } // Toggle textbox sizes, as input events have not fired here - $('#rm_group_chats_block .autoSetHeight').each(element => { - resetScrollHeight(element); - }); + if (!CSS.supports('field-sizing', 'content')) { + $('#rm_group_chats_block .autoSetHeight').each(element => { + resetScrollHeight(element); + }); + } eventSource.emit('groupSelected', { detail: { id: openGroupId, group: group } }); } @@ -1965,7 +1967,9 @@ function doCurMemberListPopout() { jQuery(() => { $(document).on('input', '#rm_group_chats_block .autoSetHeight', function () { - resetScrollHeight($(this)); + if (!CSS.supports('field-sizing', 'content')) { + resetScrollHeight($(this)); + } }); $(document).on('click', '.group_select', function () { diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index 23edce78f..b4aa080c0 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -42,9 +42,6 @@ const controls = [ { id: 'instruct_system_same_as_user', property: 'system_same_as_user', isCheckbox: true, trigger: true }, ]; -const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/'); -const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx)); - /** * Migrates instruct mode settings into the evergreen format. * @param {object} settings Instruct mode settings. @@ -103,7 +100,7 @@ export async function loadInstructMode(data) { $element.on('input', async function () { power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this).val; - if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + if (!CSS.supports('field-sizing', 'content')) { await resetScrollHeight($(this)); } saveSettingsDebounced(); diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 913b9c06b..c044c9796 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -5281,9 +5281,11 @@ $(document).ready(async function () { saveSettingsDebounced(); }); - $(document).on('input', '#openai_settings .autoSetHeight', function () { - resetScrollHeight($(this)); - }); + if (!CSS.supports('field-sizing', 'content')) { + $(document).on('input', '#openai_settings .autoSetHeight', function () { + resetScrollHeight($(this)); + }); + } if (!isMobile()) { $('#model_openrouter_select').select2({ diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index f57a15914..5270623ae 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -105,9 +105,6 @@ export const persona_description_positions = { NONE: 9, }; -const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/'); -const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx)); - let power_user = { tokenizer: tokenizers.BEST_MATCH, token_padding: 64, @@ -1757,7 +1754,7 @@ async function loadContextSettings() { power_user.context[control.property] = value; } console.log(`Setting ${$element.prop('id')} to ${value}`); - if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + if (!CSS.supports('field-sizing', 'content')) { await resetScrollHeight($(this)); } saveSettingsDebounced(); diff --git a/public/scripts/utils.js b/public/scripts/utils.js index 025eb599e..fc83b4a50 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -2027,11 +2027,8 @@ export function toggleDrawer(drawer, expand = true) { content.style.display = 'none'; } - const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/'); - const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx)); - // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height - if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + if (!CSS.supports('field-sizing', 'content')) { content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight); } }