New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sap.m.Input selectedKey binding clears Input text at start if key is not found in suggestions #2798
Comments
Hello @endrx , |
Dear @endrx , Thank you for the detailed description. When there's a selected item, nothing else matters. If this is not enough to convince you, then let's take another approach. Cheers |
Dear @d3xter666 , I used sap.m.Input like autocomplete input with searching at server (it is impossible to load all items to Input because there are many thousands of them). Items are {key, text}. And since version 1.70.0 I confused what to do. My sap.m.Input has to be initialized with some text and key. Do I really need also to add this init item to suggestions items to have init text&key in Input? I thought that suggestions are suggestions for input, not mandatory restrictions. Best Regards |
Dear @endrx , I'm not sure I understand your scenario clearly. If that is the case, initially you'd have an empty input until the backend / API call is completed and suggestions data is there. Then, is the selectedItem key and the suggestion items coming from the same request? What I've tried to explain above is that "value" and "selectedItem" could not work alongside. Always one of them would take precedence. In other words "selectedItem" would overwrite "value". You might work around this behaviour by creating temp model with an initially selected item, and when the backend call completes, it'd overwrite your temp model. However, I'm still wondering why would you need that as there would be a text in the input and later that text would be changed with something else. Am I missing something else? Best Regards |
Dear @d3xter666 , My scenario is: Many contacts in database (10000+). Each of them is having id, because contact names may be the same (although that is not ok). And some page for editing some data set, which includes a contact field. So, sap.m.Input there is supposed to give user opportunity to select one of available contacts. Suggestions are loaded from server after user has entered 2 or more characters. After pressing [Save] button on page, data set is saved to server. But this page also should allow to edit existing data sets. In this case, sap.m.Input should allow to be initialized with some contact and its id. And if user immediately presses [Save], this contact value should be saved (with id). Best Regards |
Dear @endrx , Then the current situation should be just fine. You don't need to provide explicitly text for the "value" for either scenarios. Here it is:
Cheers |
Dear d3xter666, In my case there are a lot of suggestions (>10000). It would be impossible to contain all of them in JS file. Search is planned to start when user enters 3 or more characters. Then client requests records from server with user entered text as parameter, and server returns a limited set of records, that are then inserted to Input suggestions. In previous versions of UI5 it was possible to set text and key into sap.m.Input without any suggestions provided. Or maybe there is other way to do what I need? Without using sap.m.Input with suggestions? |
@d3xter666 I think the problem @endrx is facing has to do with the fact that initially only a subset (depending on the model setting) of the There are some workarounds like manually loading the suggestion item that should be shown initially (e.g. waiting for What is the official recommendation to handle this scenario (initial suggestion item not included in the initial payload of suggestionItems)? |
@d3xter666 Please have a look at https://plnkr.co/edit/eZMfV2jICFHGWi5j I set the In this scenario even loading the entity explicitly (line 19) doesn't work, which is kinda strange IMO. Doing the same with a @endrx Please correct me if this is not the situation that you were facing. |
@jonaszuberbuehler I guess "loading the entity explicitly (line 19) doesn't work" because suggestions are using a list binding which is based on indices, and that list binding still has no idea where 'ERNSH' fits in its /Customers collection. I think UI5 should re-consider this situation and offer an end-to-end solution, thus I take the freedom to reopen this issue. |
@ThomasChadzelek Thanks! There should at least exist a clean possibility to inform the list binding about the now existing entity if this situation will not be handled by the framework itself. |
@jonaszuberbuehler "possibility to inform the list binding about the now existing entity": not sure if this is the way to go, or in other words: I cannot imagine right now how that could be done. A list binding needs to take filters etc. into account and it needs to know the entity's position within the collection. Just saying "hey, there is a 'ERNSH' within /Customers" is not enough. My naive idea would be that sap.m.Select keeps on searching (and thus requesting more data) until the selectedKey is found. Or we need a totally different mechanism to efficiently look up the selectedKey w/o reading the whole suggestionItems. There should be no need for the application to help out here. |
For the 'clean' solution there should definitely be a mechanism to hint the control how to retrieve the selected entity. Requesting more data won't be a viable solution IMO. |
@jonaszuberbuehler Isn't the selectedKey already hint enough? A "totally different mechanism to efficiently look up the selectedKey w/o reading the whole suggestionItems" could make use of that... |
@ThomasChadzelek Not sure if it is (thinking about composite keys...) but the experts will know for sure |
@jonaszuberbuehler "composite keys" - That's a good point! I missed that aspect. Thanks for your input! |
Hi guys, Sorry for being a bit late 😳 You'd need to know that this is a scenario where the functionality spreads over multiple components, but not only on the Controls level- on the one side there's the data and on the other, the controls which display that data. On the other hand, what does "selectedKey" mean in the context of the Input: It just populates the field with some text. Regarding the explicit call for the item in the oData, yes, the call updates the data, however, items aggregation is not populated for some reason. I don't think this is related to the control itself, but should be rather something with the oData model or the way the data array is being extended. Cheers |
Thanks @d3xter666
This is actually the way we're currently dealing with this situation. But it feels more like a workaround than a clean solution to me. |
Any idea what this was closed? Seems that @jonaszuberbuehler spelled out the issue pretty clearly. Seems like a tonof code to write in order to "fix" it. |
Hello @Martotko ! I am taking the freedom to reopen this issue, which does not seem to be properly solved. Please explain why you close it, in case you feel the need to close it again :-) Best regards, |
Hello @endrx, @jonaszuberbuehler I've checked the provided example in the first post - since v.1.96 sap.m.Input behaves different and the initial value is being displayed. Kind Regards, |
Not to belabor this point but it still does not work. I had to implement a workaround (ie, use a local JSON model) to get mine to work. Here is a much more detailed discussion but it's pretty easy to replicate by reducing the model size. I would strongly urge you to open this item back up as I think fixing it would really improve UI5. Regards, |
Hello @ClarkDennison, I've checked the thread in the link. This is because our users have a lot of different use cases and we want to take as most of them as we can into account. The bottom line is, we can not support all of them, it is impossible, as some of them are contradicting each other (are mutually exclusive). Regards, |
OpenUI5 version:
1.73.2
Browser/version (+device/version):
Chrome
URL (minimal example if possible):
https://next.plnkr.co/edit/CLfGEmXtMmZiPVlxo3jD
Steps to reproduce the problem:
What is the expected result?
text 'initial text' is always in Input at start.
Any other information?
in version 1.62.1 it was working as expected here.
The text was updated successfully, but these errors were encountered: