Repository navigation
feat: add API to fetch page direction - #15598
Conversation
|
This change has no dependency on the new features of the platform, and it can be back-ported to all the versions. |
mcollovati
left a comment
There was a problem hiding this comment.
Just a thought: it seems a bit odd to me that we set the direction on UI, but fetch it from Page.
Would it make sense to store direction value in UI or in UIInternals (as we do for title, for example) and have also a UI.getDirection() method?
| * to be notified when the direction is resolved. | ||
| */ | ||
| public void fetchPageDirection(SerializableConsumer<Direction> callback) { | ||
| UI.getCurrent().getPage().executeJs("return document.dir") |
There was a problem hiding this comment.
Do we need UI.getCurrent().getPage() here, since the method is not static? Could it be simply a call to executeJs?
| UI.getCurrent().getPage().executeJs("return document.dir") | |
| executeJs("return document.dir") |
There was a problem hiding this comment.
This was a left over from my draft codes, good catch!
|
Kudos, SonarCloud Quality Gate passed!
|
IMO, keeping the state for those kind of stuff that can be changed on the client-side (for instance with a custom Js script) makes it hard to keep it in sync with the corresponding value on the server side, and would make it complicated to cover corner cases, and it becomes unreliable as the result. Reading it from the browser on demand would be much simpler. But, I'm open to new ideas.
It is a little hard to decide where to put an API when it comes to decide between Page and UI, and to be honest, I also struggled over this a little, but in the end I decided to put into the Page class since it was technically close to |
|
If we don't hold state and always fetch the information from the client, I think it is fine to have the method on Page class |
Add API to fetch the document.dir from browser and pass it to the provided callback. Fixes #15597
Add API to fetch the document.dir from browser and pass it to the provided callback. Fixes #15597
|
this is a new feature, which should not be picked to maintenance branch. 23.2 and 23.3 |








Description
Add API to fetch the document.dir from browser
and pass it to the provided callback.
Fixes #15597
Type of change
Checklist
Additional for
Featuretype of change