Repository navigation
web/elements: wait for form fields to settle before submitting - #26566
Conversation
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Playwright e2eDownload 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-reportInstallation instructionsInstructions for docker-composeAdd the following block to your 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)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your 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-3b4c28d6d960b04c97ffbff6e880c1dc13e82915Afterwards, run the upgrade commands from the latest release notes. |
kensternberg-authentik
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
ad766bf to
4584eeb
Compare
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.
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.
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.
…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.
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.
This PR makes forms wait for their fields to finish loading before validating and submitting.
Form.submit()should settle its fields first, so a field that preselects a default after loading isn't sent asnullFormWizardPageno longer validates beforesubmit()