fix: disable mode select until email is entered

This commit is contained in:
Laurent Dinclaux
2026-02-27 17:44:15 +11:00
parent 54b96ef059
commit b4506a0a3e

View File

@@ -56,10 +56,13 @@ function plugin_switchIdent_init() {
$("INPUT[name='_ident_switch.form.sieve.host']").attr('placeholder', initialImapHost); $("INPUT[name='_ident_switch.form.sieve.host']").attr('placeholder', initialImapHost);
} }
// Re-apply preconfig from current email (handles form re-render after create abort // Disable mode select until a valid email is entered
// where PHP record may lack email, so readonly was not set server-side) var $modeSelect = $("SELECT[name='_ident_switch.form.common.mode']");
if (initialEmail && initialEmail.indexOf('@') > 0) { if (initialEmail && initialEmail.indexOf('@') > 0) {
$modeSelect.prop('disabled', false);
plugin_switchIdent_onEmailChange(initialEmail); plugin_switchIdent_onEmailChange(initialEmail);
} else {
$modeSelect.prop('disabled', true);
} }
} }
@@ -278,6 +281,9 @@ function plugin_switchIdent_onEmailChange(email) {
var domain = email.substring(atPos + 1).toLowerCase(); var domain = email.substring(atPos + 1).toLowerCase();
if (!domain) return; if (!domain) return;
// Enable mode select now that we have a valid email
$("SELECT[name='_ident_switch.form.common.mode']").prop('disabled', false);
// Update label and username placeholders to match current email // Update label and username placeholders to match current email
$("INPUT[name='_ident_switch.form.common.label']").attr('placeholder', email); $("INPUT[name='_ident_switch.form.common.label']").attr('placeholder', email);