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);
}
// Re-apply preconfig from current email (handles form re-render after create abort
// where PHP record may lack email, so readonly was not set server-side)
// Disable mode select until a valid email is entered
var $modeSelect = $("SELECT[name='_ident_switch.form.common.mode']");
if (initialEmail && initialEmail.indexOf('@') > 0) {
$modeSelect.prop('disabled', false);
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();
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
$("INPUT[name='_ident_switch.form.common.label']").attr('placeholder', email);