Choice fields: Ability to select arbitrary default value(s) #5063
Replies: 1 comment 1 reply
-
To address @sevmonster's last comment in the issue:
:) :), it is not that I "have a problem" or "don't want to implement it myself". It is all about what is both:
Please refrain from using such language as it is quite a turnoff for developers. No need to lecture you on how these features are being worked on for free and in the developer's own time.
Translation has never been in scope for this feature. Moreover, even if it was developed you are still left with the problem of being unable to translate:
Thus, you will be forced to create language-specific flows, stages and prompts.
There are good coding practices that should prevent you from ending up in this situation, however, that is also out of scope here. |
Beta Was this translation helpful? Give feedback.
-
The choice fields were added with PR #4822.
This discussion originated in #5045.
Problem:
Currently the choice fields do not allow an admin to (easily) select what the preselected value should be on stage load. This is because currently the preselected value is always the first item in the returned choice list from the prompt's placeholder.
While it is technically possible to rearrange the choice list dynamically on every stage load, it may not be as nice as being able to select an arbitrary default value. In addition, being able to specify more than one default value will allow the addition of a new field -
multi-select
.Current implementation
The choice fields use the prompt's placeholder to enumerate all valid choices. The current behavior is as follows:
Examples:
Example string
❌
["Example string"]
"Example string"
✔
"Example string"
Implementation limitations
Currently, all prompt model fields serve a generic purpose and are applicable to all prompt types (with rare exceptions, such as a read-only field not able to be required). This makes adding new prompt-specific fields hard to justify.
Possible solutions
Currently I am not aware of any good solutions to this problem.
The only discussed solution so far has been to return a 2-tuple from the placeholder, where the first item is the choice list and the second is either the default choice or another list containing default choices.
Example:
✔
"Str2"
This may seem a good idea at first, but there are a couple issues that need to be considered:
It is easy to return a tuple with more than 2 items in it. This is should be considered undefined behavior and should result in an error.
It is easy to return a 2-tuple (lists/sets/single values are fine) with no default choice. This is an ambiguous behavior and should also result in an error. For example:
For these reasons I consider this implementation to not be a very good UX.
Beta Was this translation helpful? Give feedback.
All reactions