Skip to content

forms(qml): a tab switch on a ready auto-submit form re-submits it, once per rebuilt control #818

Description

@Yaraslaut

Verification: reproduced locally (Windows, MSVC 14.51, Qt 6.11.1, offscreen) with DynamicForm as on master 05222af (the probe ran on a branch that does not touch the code involved). Not seen in CI; no CI case drives it.

withoutAutoSubmit(body) decrements programmaticEdit before its closing revalidate():

function withoutAutoSubmit(body) {
    form.programmaticEdit++
    try { body() } finally { form.programmaticEdit-- }
    form.revalidate()          // runs unsuppressed
}

Every control's Component.onCompleted re-seed goes through it, and a tab switch rebuilds every control of the tab. On a form that is already ready in the default auto-submit mode, each of those closing passes calls controller.submitIfValid. Probe (two tabs, one required integer, typed once, then tab 1 → 0):

QDEBUG : TabResubmit::test_switch() qml: submissions after typing 1 after two tab switches 9
FAIL!  : TabResubmit::test_switch() Compared values are not the same
   Actual   (): 9
   Expected (): 1

The header comment on programmaticEdit states the intent ("repopulating a form is not a user action and must never fire one"); the helper does not keep it. resetFields() escapes only because a cleared form is not ready. #817's prefill() hit the same thing and runs its final revalidate inside the window instead.

Fix: move form.revalidate() into the try block (before the decrement). Closes when the probe above reports 1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: formsSubsystem: formsarea: qtSubsystem: qtbugSomething isn't workingtriage: validWell-framed; implement as written

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions