# Bug COMMS-891 - SMTP configuration fields never appear on Email notifications settings page

Project: Stream Communicator
Status: closed
URL: https://community.openproject.org/work_packages/COMMS-891

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | High |
| Module | Modules and project features / Email notifications, Administration |
| Target versions | 17.8.0 |
| Observed in versions | 17.5.0 |
| Sprint | Sprint 11: Versions stabilization |
| Backlog bucket |  |
| Bug found in version (deprecated) | 17.5.x |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | Tom Hykel |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  On a fresh instance (outgoing email not yet configured), go to
    
2.  Administration &gt; Emails and notifications &gt; Email notifications ( /admin/settings/mail\_notifications ).
    
3.  Observe the &quot;Email delivery method&quot; dropdown. It displays &quot;SMTP&quot;.
    
4.  Try to enter your SMTP server / port / username / password.
    

### What is the buggy behavior?

There are no SMTP fields on screen. The &quot;Email delivery method&quot; dropdown already shows &quot;smtp&quot;, 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 &quot;smtp&quot; (the value already shown) does nothing, because selecting the already-selected value does not emit a &#x60;change&#x60; event. The only way to make the fields appear is the non-obvious workaround of selecting &quot;sendmail&quot; first and then switching back to &quot;smtp&quot;, which finally fires a &#x60;change&#x60; event and reveals the fields. The fields are hidden again on every subsequent page load.

### What is the expected behavior?

On page load, the SMTP field group should be shown whenever the &quot;Email delivery method&quot; dropdown&#x27;s current value is &quot;smtp&quot; (and the sendmail field group when it is &quot;sendmail&quot;), 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 &#x60;toggleDisabled&#x60; into a

shared method and call it from both &#x60;causeTargetConnected&#x60; and the change handler.

&#x60;frontend/src/stimulus/controllers/show-when-value-selected.controller.ts&#x60;:

causeTargetConnected(target: HTMLInputElement | HTMLSelectElement) {

target.addEventListener(&#x27;change&#x27;, this.boundListener);

this.applyFor(target); &nbsp;                     // &lt;-- NEW: evaluate initial state on load

}

causeTargetDisconnected(target: HTMLInputElement | HTMLSelectElement) {

target.removeEventListener(&#x27;change&#x27;, 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) =&gt; targetName === el.dataset.targetName)

.forEach((el) =&gt; {

const disabled = this.willDisable(el, input.value);

(el as HTMLInputElement).disabled = disabled;

if (el.dataset.setVisibility === &#x27;true&#x27;) {

toggleElementByVisibility(el, !disabled);

} else {

toggleElement(el, !disabled);

}

});

}

This preserves the existing change-driven behaviour exactly (it just calls the same logic

from &#x60;applyFor&#x60;) 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.
