What is the expected behavior when a selected select value is temporarily removed?
- Dominant language
- TypeScript
- Stars
- 38
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
Breaking out an issue to track [this discussion thread][discussion thread] on #14.
## Current (albeit incomplete) behavior
The intent of the behavior in #14 (which is incomplete, as called out in the comment) is this:
**Given a form like:**
```xml
option a
option b
```
### If a user...
1. Answers `/data/sel`, selecting "option a"
2. Answers `/data/fil`, entering "b" (causing "option a" to be removed from `/data/sel`'s available items)
**Then** the form state is updated so that the prior selection of "option a" is:
- Cleared from `/data/sel`
- Retained in memory until[^1] another selection is performed with the filtered options for `/data/sel`
At this point, the form's **instance state** is correct, but it allows _either_:
### Next (A), if a user...
3. Answers `/data/sel` again, selecting "option b"
**Then** the form state is updated so that:
- `/data/sel` is set to "option b"
- The previous selection of "option a" will[^1] no longer be retained
4. Clears `/data/fil` (restoring "option a" as an available option for `/data/sel`)
**Then** the form state for `/data/sel` is unchanged from step 3
... OR ...
### Next (B), if a user...
3. Clears `/data/fil` (restoring "option a" as an available option for `/data/sel`) _without any further user action on `/data/sel` following step 1's affirmative selection of "option a"_
**Then** the form state is restored to its state after step 1 (i.e. the value of `/data/sel` is again set to "option a")
## Alternative behavior
Per the [discussion thread][discussion thread], the alternative would be not to retain any memory that "option a" had been chosen (step 1), once that option is filtered out (step 2). Also per the discussion thread, this is the behavior in JavaRosa. Furthermore, it would be fair to say it is the **obvious default behavior**. It is unquestionably the behavior we'd implement if we skip asking the question posed by this issue.
[discussion thread]: https://github.com/getodk/web-forms/pull/14#discussion_r1516639281
[^1]: This aspect is currently unhandled, but will be handled the same way regardless of the broader answer to the question posed by this issue.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked discussion on pull request #14 and the related issue #14, then compare the two behaviors described here for a filtered select value. The immediate goal is to resolve which behavior is expected and record that decision; implementation work should follow only after the design question is settled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100