Skip to content

Fix stale selections when filling select controls - #958

Open
peterolkhov wants to merge 1 commit into
AnswerDotAI:mainfrom
peterolkhov:codex/replace-filled-select-selections
Open

peterolkhov wants to merge 1 commit into
AnswerDotAI:mainfrom
peterolkhov:codex/replace-filled-select-selections

Conversation

@peterolkhov

Copy link
Copy Markdown

Related Issue

Fixes #957.

Proposed Changes

fill_form currently adds selections to a select without removing existing ones. For example, a multiple select with default a, filled with ['b'], renders both a and b selected; filling it with [] leaves a selected.

Clear the existing option selections before applying a supplied value. This also preserves the existing first-match behavior for scalar values. Missing and None values, skipped controls, unrelated attributes, and other form controls retain their current behavior.

The change is made in the source notebook and exported to components.py. Notebook tests cover replacement, clearing, defaults, scalar duplicates, preserve controls, and the adjacent form controls.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I am aware that this is an nbdev project, and I have edited, cleaned, and synced the source notebooks instead of editing .py or .md files directly.

Additional Information

Prepared with OpenAI Codex. The added component notebook test fails on unchanged upstream and passes with the fix. Validation used Python 3.12.13: the focused notebook and full nbdev-test --n-workers 0 pass, along with nbdev-export, nbdev-clean, and nbdev-trust. A second export/clean leaves the changed files unchanged. The full test run honors the project's existing skip_exec directives; no browser submission, external provider, or deployment test was run.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] fill_form retains stale selections when filling a select

1 participant