fix(playground): restore select value's text from local storage
Some checks failed
Deploy Docs / deploy-docs (push) Waiting to run
CI / sanitize (push) Failing after 12s
CI / build (push) Failing after 14s
CI / checks (push) Has been cancelled

This commit is contained in:
Amaan Qureshi 2024-12-25 20:21:16 -05:00
parent e3b2545ab7
commit c615c0996f

View file

@ -18,7 +18,7 @@ function initializeLocalTheme() {
});
}
function initializeCustomSelect() {
function initializeCustomSelect(initialValue = null) {
const button = document.getElementById('language-button');
const select = document.getElementById('language-select');
if (!button || !select) return;
@ -26,6 +26,9 @@ function initializeCustomSelect() {
const dropdown = button.nextElementSibling;
const selectedValue = button.querySelector('.selected-value');
if (initialValue) {
select.value = initialValue;
}
selectedValue.textContent = select.options[select.selectedIndex].text;
button.addEventListener('click', (e) => {
@ -565,6 +568,7 @@ window.initializePlayground = async function initializePlayground(opts) {
queryInput.value = query;
codeInput.value = sourceCode;
languageSelect.value = language;
initializeCustomSelect(language);
anonymousNodes.checked = anonNodes === "true";
queryCheckbox.checked = queryEnabled === "true";
}