SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.9k stars 1.23k forks source link

Can't get focusInfo in serchField correctly #4059

Closed mengmeng0813 closed 1 month ago

mengmeng0813 commented 1 month ago

OpenUI5 version: all

Browser/version (+device/version): Google Chrome: Version 125.0.6422.113 (Official Build) (x86_64)

Any other tested browsers/devices(OK/FAIL):

URL (minimal example if possible): https://sapui5.hana.ondemand.com/#/entity/sap.m.SearchField/sample/sap.m.sample.SearchFieldSuggestions/code

User/password (if required and possible - do not post any confidential information here):

Steps to reproduce the problem:

  1. open code editor, add "console.log(this.byId("searchField").getFocusInfo());" in onsuggest function
  2. focus on searchField, select an Item in suggestion lists
  3. blur and refocus on searchField, the focusInfo is not correct

image

What is the expected result? No mater where I focus in searchField, the cursor position should be right.

What happens instead? Most of the time, it returns an error cursor position

Any other information? (attach screenshot if possible)

niyap commented 1 month ago

Hello @mengmeng0813 ,

Thank you for sharing this finding. I've created an internal incident DINC0173519. The status of the issue will be updated here in GitHub.

Regards, Niya

TeodorTaushanov commented 1 month ago

Hi,

In your case you can get the correct cursor position with the following code:

function onSuggest(event) {
        setTimeout(function () {
            console.error(event.oSource.getFocusInfo());
        }, 0);
    }

Best, Teo