Skip to content

Impl. clearable dropdown#2209

Merged
mvorisek merged 17 commits intodevelopfrom
clearable_dropdown
Jan 10, 2025
Merged

Impl. clearable dropdown#2209
mvorisek merged 17 commits intodevelopfrom
clearable_dropdown

Conversation

@mvorisek
Copy link
Copy Markdown
Member

@mvorisek mvorisek commented Jun 1, 2024

simillar to 6fcc1f2

fix #572
fix #2026

@mvorisek mvorisek force-pushed the clearable_dropdown branch 2 times, most recently from 99509b2 to 1fde92a Compare June 18, 2024 14:30
@mvorisek mvorisek force-pushed the clearable_dropdown branch 2 times, most recently from e30c12a to 1f450c5 Compare January 9, 2025 20:46
@mvorisek mvorisek force-pushed the clearable_dropdown branch 2 times, most recently from f0e6f8a to 47899f6 Compare January 10, 2025 08:58
@mvorisek mvorisek marked this pull request as ready for review January 10, 2025 11:26
@mvorisek mvorisek added the MAJOR label Jan 10, 2025
@mvorisek mvorisek merged commit dcb3ffa into develop Jan 10, 2025
@mvorisek mvorisek deleted the clearable_dropdown branch January 10, 2025 13:41
@mkrecek234
Copy link
Copy Markdown
Contributor

Hi @mvorisek With this PR, Lookup fields always get a clearable icon if they are either nullable or not required. I am of the opinion that

a) clearable should only be activated by default if the field is not required and is nullable at the same time
b) it should still be possible to override this default behaviour using setDropdownOption('clearable', false) - currently not possible as it is forced on rendering.

Furthermore I saw that on a disabled/readOnly field with `multiple = true, the clearable icon was present allowing the erase the dropdown field.

Let me know if you agree, then I can work on a PR to suggest a change.

@mvorisek
Copy link
Copy Markdown
Member Author

Hi Michael, "almost always clearable" - what are the usecases? User should be able to revert any chenge he did on the UI side, so after selecting an option it should be always possible to clear it. The validation on send is of course always working.

"multiple" - if there is an issue, PR with testcase highly welcomed!

@rickyosser
Copy link
Copy Markdown
Contributor

rickyosser commented May 9, 2025

Hi Michael, "almost always clearable" - what are the usecases? User should be able to revert any chenge he did on the UI side, so after selecting an option it should be always possible to clear it. The validation on send is of course always working.

"multiple" - if there is an issue, PR with testcase highly welcomed!

@mvorisek it's all well as long as you actually use a model to populate the dropdown. In my case I'm not using any models at all in my current project as all DB/data related handling is done through a rest-api. I'm just using atk4 for building the GUI. In that case creating a dropdown using setSource I will not be able to add validation in the model, I could use a check in the callback but as I'm not really interested in what the user chooses, as any value except no value is acceptable. I could use radio-buttons instead but that uses more screen-area than needed to have a minimal and consistent look.

I would prefer to have setDropdownOption('clearable', false) honoured.
I will create a PR for it so you can check if it's ok to implement. (Calling @mkrecek234 for comments as well.)

@mkrecek234
Copy link
Copy Markdown
Contributor

@rickyosser Fully agree that we should still be able to programmatically configure the clearable setting, independent of the default, model-based logic. There are some use cases where the data structure allows nullable and non-required values, but you want the UI to force the user to choose a value. So needs to be independently configurable for sure.

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

Labels

Development

Successfully merging this pull request may close these issues.

Dropdown/lookup field shows empty value for required model fields Lookup field with empty value doesn't show placeholder

3 participants