Content
View differences
Updated by Wieland Lindenthal 3 days ago
###
### Steps to reproduce
1. On a fresh instance (outgoing email not yet configured), go to
2. Administration > Emails and notifications > Email notifications ( /admin/settings/mail\_notifications ).
3. Observe the "Email delivery method" dropdown. It displays "SMTP".
4. Try to enter your SMTP server / port / username / password.
### What is the buggy behavior?
There are no SMTP fields on screen. The "Email delivery method" dropdown already shows
"smtp", but the SMTP server / port / authentication / username / password inputs are not
displayed, so there is nowhere to type the settings.
Clicking the dropdown and selecting "smtp" (the value already shown) does nothing,
because selecting the already-selected value does not emit a `change` event. The only
way to make the fields appear is the non-obvious workaround of selecting "sendmail"
first and then switching back to "smtp", which finally fires a `change` event and
reveals the fields. The fields are hidden again on every subsequent page load.
### What is the expected behavior?
<br>
On page load, the SMTP field group should be shown whenever the "Email delivery method"
dropdown's current value is "smtp" (and the sendmail field group when it is "sendmail"),
without requiring the user to toggle the dropdown. The visible state of the conditional
fields should always match the currently selected delivery method, including on initial
render.
###
### Environment information
**Browser**
* [x] Chrome
* [ ] Firefox
* [ ] Safari
* [ ] Mobile Safari
* [ ] Other (please specify)
**Operating System**
* [ ] Windows
* [ ] Mac OS X
* [ ] Mobile iOS
* [ ] Mobile Android
* [x] Linux (please specify distro) (see below)
* [ ] Chrome OS
* [ ] Other (please specify)
**Language**
_Please specify the browser language and the language of the OpenProject user for which the bug occurred._
**\===========================================================================================**
SUGGESTED CODE FIX
**\===========================================================================================**
Evaluate the current state once when the cause element connects, so the conditional
fields render correctly on load. Factor the existing body out of `toggleDisabled` into a
shared method and call it from both `causeTargetConnected` and the change handler.
`frontend/src/stimulus/controllers/show-when-value-selected.controller.ts`:
causeTargetConnected(target: HTMLInputElement | HTMLSelectElement) {
target.addEventListener('change', this.boundListener);
this.applyFor(target); // <-- NEW: evaluate initial state on load
}
causeTargetDisconnected(target: HTMLInputElement | HTMLSelectElement) {
target.removeEventListener('change', this.boundListener);
}
toggleDisabled(evt: Event) {
this.applyFor(evt.target as HTMLInputElement | HTMLSelectElement); // unchanged behaviour
}
private applyFor(input: HTMLInputElement | HTMLSelectElement) {
const targetName = input.dataset.targetName;
this.effectTargets
.filter((el) => targetName === el.dataset.targetName)
.forEach((el) => {
const disabled = this.willDisable(el, input.value);
(el as HTMLInputElement).disabled = disabled;
if (el.dataset.setVisibility === 'true') {
toggleElementByVisibility(el, !disabled);
} else {
toggleElement(el, !disabled);
}
});
}
This preserves the existing change-driven behaviour exactly (it just calls the same logic
from `applyFor`) and additionally reconciles visibility on connect, so the SMTP/sendmail
groups always match the selected delivery method on first render.
**\===========================================================================================**
ENVIRONMENT SUMMARY
**\===========================================================================================**
Product / version : OpenProject 17.5.1, Community edition
Installation : Packaged (DEB) install
OS : Debian 12
Web server : Apache/2.4.67 (Debian), HTTP (no TLS)
Affected file : frontend/src/stimulus/controllers/show-when-value-selected.controller.ts
Affected page : /admin/settings/mail\_notifications
Severity : Medium — blocks configuring outgoing email through the web UI on a
fresh install; not a crash and has a non-obvious workaround.
###
1. On a fresh instance (outgoing email not yet configured), go to
2. Administration > Emails and notifications > Email notifications ( /admin/settings/mail\_notifications ).
3. Observe the "Email delivery method" dropdown. It displays "SMTP".
4. Try to enter your SMTP server / port / username / password.
### What is the buggy behavior?
There are no SMTP fields on screen. The "Email delivery method" dropdown already shows
### What is the expected behavior?
**Browser**
* [x] Chrome
* [ ] Firefox
* [ ] Safari
* [ ] Mobile Safari
* [ ] Other (please specify)
**Operating System**
* [ ] Windows
* [ ] Mac OS X
* [ ] Mobile iOS
* [ ] Mobile Android
* [x] Linux (please specify distro) (see below)
* [ ] Chrome OS
* [ ] Other (please specify)
**Language**
_Please specify the browser language and the language of the OpenProject user for which the bug occurred._
**\===========================================================================================**
SUGGESTED CODE FIX
**\===========================================================================================**
Evaluate the current state once when the cause element connects, so the conditional
fields render correctly on load. Factor the existing body out of `toggleDisabled` into a
shared method and call it from both `causeTargetConnected` and the change handler.
`frontend/src/stimulus/controllers/show-when-value-selected.controller.ts`:
causeTargetConnected(target: HTMLInputElement | HTMLSelectElement) {
target.addEventListener('change', this.boundListener);
this.applyFor(target); // <-- NEW: evaluate initial state on load
}
causeTargetDisconnected(target: HTMLInputElement | HTMLSelectElement) {
target.removeEventListener('change', this.boundListener);
}
toggleDisabled(evt: Event) {
this.applyFor(evt.target as HTMLInputElement | HTMLSelectElement); // unchanged behaviour
}
private applyFor(input: HTMLInputElement | HTMLSelectElement) {
const targetName = input.dataset.targetName;
this.effectTargets
.filter((el) => targetName === el.dataset.targetName)
.forEach((el) => {
const disabled = this.willDisable(el, input.value);
(el as HTMLInputElement).disabled = disabled;
if (el.dataset.setVisibility === 'true') {
toggleElementByVisibility(el, !disabled);
} else {
toggleElement(el, !disabled);
}
});
}
This preserves the existing change-driven behaviour exactly (it just calls the same logic
from `applyFor`) and additionally reconciles visibility on connect, so the SMTP/sendmail
groups always match the selected delivery method on first render.
**\===========================================================================================**
ENVIRONMENT SUMMARY
**\===========================================================================================**
Product / version : OpenProject 17.5.1, Community edition
Installation : Packaged (DEB) install
OS : Debian 12
Web server : Apache/2.4.67 (Debian), HTTP (no TLS)
Affected file : frontend/src/stimulus/controllers/show-when-value-selected.controller.ts
Affected page : /admin/settings/mail\_notifications
Severity : Medium — blocks configuring outgoing email through the web UI on a
fresh install; not a crash and has a non-obvious workaround.