Fix form <select> value not being up to date by the time we auto-submit the form on selection (#105)

Follow-up to https://github.com/matrix-org/matrix-public-archive/pull/102#discussion_r1002190782
This commit is contained in:
Eric Eastwood 2022-10-21 16:24:22 -05:00 committed by GitHub
parent d2d6c5a580
commit 7c09ac13f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -183,8 +183,16 @@ class RoomDirectoryView extends TemplateView {
// modal close callback but this races with it and sometimes we beat it.
const path = vm.navigation.pathFrom([]);
vm.navigation.applyPath(path);
// Submit the page with the new homeserver selection to get results.
headerForm.submit();
// Set the `<select>` value before we submit to ensure we have the most up to
// date information. Normally this would be updated by having Hydrogen do its
// render cycle and have the `<option selected>` be swapped around.
homeserverSelectElement.value = homeserverSelection;
setTimeout(() => {
// Submit the page with the new homeserver selection to get results.
headerForm.submit();
}, 0);
}
}
);