Combobox completion, Case Sensitivity

asked 2023-07-05 14:17:16 +0800

NetLaborlw gravatar image NetLaborlw


if I use a combobox with a backing listmodel for the dropdown menu it always corrects the spelling of the entered Text accoriding to its items. E.g. the model contains "abc". But if I enter "Abc" or "ABC" it gets changed to "abc". Is there a way to disable this behaviour temporarely and force the combobox to accept a different capitalization of words? This behaviour does not depent on the settings of autodrop or autocomplete. However you can test this behaviour in your the combobox demo www.zkoss.org/zkdemo/combobox/autocomplete. I would like to have a key combination, e.g. pressing ESC, that forces the combobox to accept whatever text is inside without correcting it.

Thank you,

All the best Leo

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2023-07-08 01:27:46 +0800

MDuchemin gravatar image MDuchemin
2390 1 6
ZK Team

Hey there,

The behavior you describe is actually caused by autocomplete.

The way autocomplete works is as follow: after typing a letter into the the combobox, the combobox will search the existing comboitems. If it finds at least one comboitem that starts with the same string as the input value (not case sensitive), it will mark that comboitem as selected, and replace the content of the input with the content of the target item's label.

If you set autocomplete to false, the combobox will not automatically fill the input with the label of the first search result, which allows the user to type a string with a different capitalization.

See the difference here: https://zkfiddle.org/sample/1u2s3n0/7-Another-new-ZK-fiddle

if you try to type: "e" (wait for popup to display items) then "N", the value will be autocompleted to en_US in the first one, but will receive just eN in the 2nd case.

Now in the "what can you do about this" section: What would you like to happen? ZK is very customizable. If the intent is to only autocomplete on exact case-sensitive strings, that would be a customizable option.

Here's a fiddle that shows an override to the combobox class which force cases-sensitiveness to completion https://zkfiddle.org/sample/3jl0gdt/2-Combobox-disable-case-completion

Note: this override is global (it affects all comboboxes that will be created in that page). If you want a granular approach to set that behavior on some combobox and not other, the same logic can be used but using an extended class instead.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2023-07-05 14:17:16 +0800

Seen: 5 times

Last updated: Jul 08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More