Skip to content

IdP create form is dirty immediately (dev only) #2913

@david-crespo

Description

@david-crespo

Bug found while working on #2912, but it turns out to happen on main, too. This only happens in dev, so it's very low priority.

useEffect(() => {
// When creating a SAML identity provider connection, the ACS URL that the user enters
// should always be of the form: http(s)://<silo>.sys.<suffix>/login/<silo>/saml/<name>
// where <silo> is the Silo name, <suffix> is the delegated domain assigned to the rack,
// and <name> is the name of the IdP connection
// The user can override this by unchecking the "Automatically generate ACS URL" checkbox
// and entering a custom ACS URL, though if they check the box again, we will regenerate
// the ACS URL.
const suffix = getDelegatedDomain(window.location)
if (generateUrl) {
form.setValue('acsUrl', `https://${silo}.sys.${suffix}/login/${silo}/saml/${name}`)
}
}, [form, name, silo, generateUrl])

This effect is causing the form to become dirty on initial mount, causing a nav confirm when you try to leave the form, even though you haven't done anything. Key facts:

  • I know it's that setValue because when I comment it out the problem goes away
  • This is only true in development, where React's strict mode is running all effects twice, so it's probably some kind of race
  • Adding { shouldDirty: false } to the setValue does not help (setValue docs)
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions