Skip to content

web/elements: wait for form fields to settle before submitting - #26566

Merged
GirlBossRush merged 3 commits into
mainfrom
web/form-settle
Oct 6, 2026
Merged

GirlBossRush merged 3 commits into
mainfrom
web/form-settle

Conversation

@GirlBossRush

@GirlBossRush GirlBossRush commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

This PR makes forms wait for their fields to finish loading before validating and submitting.

  • Fixed an issue where Form.submit() should settle its fields first, so a field that preselects a default after loading isn't sent as null
  • FormWizardPage no longer validates before submit()

@netlify

netlify Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 4584eeb
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6ac46791762e4e00086b3d7d
😎 Deploy Preview https://deploy-preview-26566--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.33%. Comparing base (168723e) to head (3b4c28d).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #26566   +/-   ##
=======================================
  Coverage   92.33%   92.33%           
=======================================
  Files        1175     1175           
  Lines       77789    77789           
  Branches     4129     4129           
=======================================
+ Hits        71827    71828    +1     
+ Misses       5896     5895    -1     
  Partials       66       66           
Flag Coverage Δ
conformance 32.92% <ø> (ø)
e2e 37.72% <ø> (+<0.01%) ⬆️
integration 29.71% <ø> (+<0.01%) ⬆️
rust 46.45% <ø> (ø)
unit 93.75% <ø> (+<0.01%) ⬆️
unit-migrate 93.75% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Playwright e2e

Download this run's HTML report and traces, then open the report:

gh run download 37409275982 -D playwright-artifacts
npx playwright show-report playwright-artifacts/playwright-report

Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-3b4c28d6d960b04c97ffbff6e880c1dc13e82915
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-3b4c28d6d960b04c97ffbff6e880c1dc13e82915

Afterwards, run the upgrade commands from the latest release notes.

@GirlBossRush GirlBossRush self-assigned this Sep 30, 2026
@GirlBossRush GirlBossRush added the area:frontend Features or issues related to the browser, TypeScript, Node.js, etc label Sep 30, 2026

@kensternberg-authentik kensternberg-authentik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly edge conditions. Some could be bothersome. Good enough, though. Better than what we've got now.

this.dispatchNavigationEvent({
disabled: ["bindings", "submit"],
});
void this.#next(button);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this void do?

Some fields only know their value once they have loaded their options, e.g. a
search select that preselects a default flow. A form submitted before then
serialized them empty.

- Add a SettlingFormField contract (a `settled` promise) and
  settleFormFields(), which waits on every settling field in a form.
- Form.submit() settles the form's fields before validating and serializing.
- FormWizardPage no longer pre-validates before submit(), which settles and
  validates itself, and treats a `false` result as a failed step.
- The application wizard's provider step settles before checking validity.
Move the settle helpers into a DOM-free module so they can be unit
tested, give settleFormFields a timeout so a stalled field request
can't hang submission, and ignore repeated "next" clicks while the
provider step is still settling.
…listen

CustomEmitterElement and CustomListenerElement predate typed Event subclasses
and the @listen decorator. Remove both and eventEmitter.ts.

- ak-dual-select: DualSelectEvent and SearchbarEvent, registered in
  GlobalEventHandlersEventMap with the same `detail` shapes as before. The
  provider listens with @listen, which also stops it re-adding its listeners
  on every reconnect.
- BaseTaskButton, ak-checkbox-group, and the application wizard's submit step
  dispatch plain events (the latter an AKRefreshEvent).
- The search wrappers drop the listener mixin they never used.

Fix @listen along the way:
- Its docs said listeners attach to `window`; the default target is the
  element itself.
- A subclass adding its own @listen wrapped the parent's lifecycle hooks a
  second time, leaving the parent's listeners attached after disconnect.
- Reconnecting without a disconnect no longer stacks registrations.
- Plain methods are bound to the element, so `this` is right for any target.
@GirlBossRush
GirlBossRush merged commit 2547ba4 into main Oct 6, 2026
236 of 240 checks passed
@GirlBossRush
GirlBossRush deleted the web/form-settle branch October 6, 2026 04:08
GirlBossRush added a commit that referenced this pull request Oct 6, 2026
Rebasing onto main brought in settle-form-fields.ts from #26566, while this
branch still carried its own earlier copy of settleFormFields and
SettlingFormField in form-associated-element.ts. Form.ts imported both, which
failed type checking with a duplicate identifier.

Keeps main's version, which also times out and never rejects, and points
Form and ak-search-select at it.
GirlBossRush added a commit that referenced this pull request Oct 8, 2026
Rebasing onto main brought in settle-form-fields.ts from #26566, while this
branch still carried its own earlier copy of settleFormFields and
SettlingFormField in form-associated-element.ts. Form.ts imported both, which
failed type checking with a duplicate identifier.

Keeps main's version, which also times out and never rejects, and points
Form and ak-search-select at it.
GirlBossRush added a commit that referenced this pull request Oct 8, 2026
…25610)

* web/elements: wait for form fields to settle before submitting

Some fields only know their value once they have loaded their options, e.g. a
search select that preselects a default flow. A form submitted before then
serialized them empty.

- Add a SettlingFormField contract (a `settled` promise) and
  settleFormFields(), which waits on every settling field in a form.
- Form.submit() settles the form's fields before validating and serializing.
- FormWizardPage no longer pre-validates before submit(), which settles and
  validates itself, and treats a `false` result as a failed step.
- The application wizard's provider step settles before checking validity.

* web/elements: rebuild ak-search-select as a form-associated element

Replace ak-search-select, its view, ak-list-select, and the EZ variant with a single
form-associated element built on the platform: a native combobox input, a popover
listbox positioned with CSS anchor positioning (with a JS fallback for Firefox), and
ElementInternals for its value and validity.

- `value` is the chosen key. Options come from a SearchSelectSource (fetchObjects,
  keyOf, labelOf, describe, isDisabled, groupBy, preselect). `selectedObject` labels
  the field before the options load, and the selection stays listed when it isn't on
  the fetched page.
- `settled` resolves once the latest fetch lands, for Form.submit() to wait on.
- Keyboard navigation with aria-activedescendant, a pinned action item, a blank
  option, creatable free text, and closing on outside clicks even when focus stays in
  the input. A late preselection doesn't close an open menu.
- The input takes its accessible name from `label`, the field's <label>, or the
  enclosing horizontal form element, since none can reach it across the shadow root.
- `emptyValue` sets what an empty field serializes as, for string fields.

Component tests cover the element.

* web: add search select components and shared sources

Replace the per-type wrapper elements with function components over the new element:
AKSearchSelect and AKSearchSelectField, AKFlowSearch and AKFlowField, and
AKCertificateSearch. Shared sources for policies, groups, users, device access groups,
roles, and notification mappings live in #admin/common/search-sources.
ak-file-search-input moves onto a file source with free-text values.

* web/admin: add presets for provider and source flow fields

The authorization, authentication, and invalidation flow fields repeat across the
provider forms, and the pre-authentication, authentication, and enrollment flow fields
across the source forms. So do the SAML NameID and AuthnContextClassRef mapping fields.
Each becomes a field preset with the shared wording, which forms can override.

* web/admin: move provider forms onto the new search select

Also fixes the brand's default flows never preselecting in the LDAP and RADIUS
provider forms: the brand stores slugs, not primary keys.

* web/admin: move source forms onto the new search select

* web/admin: move stage and flow forms onto the new search select

* web/admin: move application and policy forms onto the new search select

* web/admin: move the remaining forms onto the new search select

Brands, outposts, events, RBAC, blueprints, endpoints, lifecycle rules, requests,
tokens, users, object attributes, property mapping tests, and sync objects. Blueprint
paths serialize as an empty string when unset, since the field isn't nullable.

* web/test: cover the new search select end to end

The form fixture finds search selects by their label and chooses options by role.
New cases cover a default flow still loading at submit, keyboard and search, outside
clicks, edit forms showing saved values, and a group binding in the application
wizard.

* web/elements: drop the settle helpers duplicated from main

Rebasing onto main brought in settle-form-fields.ts from #26566, while this
branch still carried its own earlier copy of settleFormFields and
SettlingFormField in form-associated-element.ts. Form.ts imported both, which
failed type checking with a duplicate identifier.

Keeps main's version, which also times out and never rejects, and points
Form and ak-search-select at it.

* web/admin: save the LDAP source's parent group; scope create clicks in tests

The LDAP source form submitted its parent group as `additionalParentGroup`,
a name the API doesn't know, so the group never saved. Submit it as
`syncParentGroup`.

The admin tables render a second create button in their empty state while rows
load, so an unscoped "New …" click could match two buttons. Scope those clicks
in the e2e tests to the table toolbar, as the provider tests already do.

* web/elements: send numeric keys to the API as numbers; keep option IDs unique

- Sources can declare parseKey(); the user and provider sources send their
  primary keys as numbers again, matching main.
- Object option IDs get their own prefix and an unambiguous encoding, so keys
  like "blank" or "action" no longer collide with the built-in options.
- The active option scrolls into view by its rendered ID.

* web/elements: settle form fields before wizard and modal validation

Wizard steps and modal forms checked validity synchronously before waiting for
fields to settle, so a required search select still preselecting its default
rejected the click and never retried.

- WizardStep waits for settled() before validating Next/Finish and ignores
  repeat clicks meanwhile; ApplicationWizardStep settles its form.
- ModalForm settles the form before its validity check.
- Cover the provider step with an e2e test that holds back the invalidation flows.
BeryJu pushed a commit that referenced this pull request Oct 20, 2026
Form.submit() became async in #26566 and now awaits settleFormFields()
before serializing. That gives the host form a chance to re-render first,
and Lit re-assigns array property bindings on every render, so
`.items=${settings.footerLinks}` reset the list to the server's copy and
the PUT went out with stale values.

The items setter now ignores a list whose contents match the one the
parent last assigned.

This also fixes a long-standing keying bug. The setter's map callback had
its arguments swapped, so every row got a fresh key on each change and
`repeat` rebuilt it. Clicking from one field into another in the same row
sent the next keystrokes into a detached input. Edits, adds and deletes now
operate on the keyed list directly, and delete removes the clicked row by
key instead of by index.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Features or issues related to the browser, TypeScript, Node.js, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants