Fix regression in handling select elements in packs/admin.tsx (#29469)

This commit is contained in:
Claire 2024-03-01 11:16:35 +01:00 committed by GitHub
parent b9940eb977
commit ec953bf378
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -149,7 +149,7 @@ Rails.delegate(
}, },
); );
const onDomainBlockSeverityChange = (target: HTMLInputElement) => { const onDomainBlockSeverityChange = (target: HTMLSelectElement) => {
const rejectMediaDiv = document.querySelector( const rejectMediaDiv = document.querySelector(
'.input.with_label.domain_block_reject_media', '.input.with_label.domain_block_reject_media',
); );
@ -169,7 +169,7 @@ const onDomainBlockSeverityChange = (target: HTMLInputElement) => {
}; };
Rails.delegate(document, '#domain_block_severity', 'change', ({ target }) => { Rails.delegate(document, '#domain_block_severity', 'change', ({ target }) => {
if (target instanceof HTMLInputElement) onDomainBlockSeverityChange(target); if (target instanceof HTMLSelectElement) onDomainBlockSeverityChange(target);
}); });
const onEnableBootstrapTimelineAccountsChange = (target: HTMLInputElement) => { const onEnableBootstrapTimelineAccountsChange = (target: HTMLInputElement) => {
@ -206,7 +206,7 @@ Rails.delegate(
}, },
); );
const onChangeRegistrationMode = (target: HTMLInputElement) => { const onChangeRegistrationMode = (target: HTMLSelectElement) => {
const enabled = target.value === 'approved'; const enabled = target.value === 'approved';
document document
@ -256,7 +256,7 @@ Rails.delegate(
'#form_admin_settings_registrations_mode', '#form_admin_settings_registrations_mode',
'change', 'change',
({ target }) => { ({ target }) => {
if (target instanceof HTMLInputElement) onChangeRegistrationMode(target); if (target instanceof HTMLSelectElement) onChangeRegistrationMode(target);
}, },
); );
@ -286,11 +286,11 @@ async function mountReactComponent(element: Element) {
} }
ready(() => { ready(() => {
const domainBlockSeverityInput = document.querySelector<HTMLInputElement>( const domainBlockSeveritySelect = document.querySelector<HTMLSelectElement>(
'input#domain_block_severity', 'select#domain_block_severity',
); );
if (domainBlockSeverityInput) if (domainBlockSeveritySelect)
onDomainBlockSeverityChange(domainBlockSeverityInput); onDomainBlockSeverityChange(domainBlockSeveritySelect);
const enableBootstrapTimelineAccounts = const enableBootstrapTimelineAccounts =
document.querySelector<HTMLInputElement>( document.querySelector<HTMLInputElement>(
@ -299,8 +299,8 @@ ready(() => {
if (enableBootstrapTimelineAccounts) if (enableBootstrapTimelineAccounts)
onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts); onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts);
const registrationMode = document.querySelector<HTMLInputElement>( const registrationMode = document.querySelector<HTMLSelectElement>(
'input#form_admin_settings_registrations_mode', 'select#form_admin_settings_registrations_mode',
); );
if (registrationMode) onChangeRegistrationMode(registrationMode); if (registrationMode) onChangeRegistrationMode(registrationMode);