You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was just about to use the PermissionController to be able to work with the geolocations or to display the UI in a slightly different way depending on the state. I'm not sure if I'm doing something wrong or not, but the initial state doesn't seem to correspond to the actual state. I followed the demo in the docs and added some UI with help from lit/task, both in Chrome and Firefox the initial state after I open the page is “prompt” no matter if the permission was granted or denied.
i think its a bug and we should explicitly call this.__host.requestUpdate() in the bottom of initialisePermissions
would you be open to contributing it?
should be as simple as this:
async__initialisePermissions(name){this.__status=awaitnavigator.permissions.query({ name });this.__status.addEventListener('change',this.__onPermissionChanged);this.__host.requestUpdate();// <- this line fixes it i think}
and adding a test for that (by somehow mocking the query to be granted and ensuring it renders the right value)
Hi there!
I was just about to use the PermissionController to be able to work with the geolocations or to display the UI in a slightly different way depending on the state. I'm not sure if I'm doing something wrong or not, but the initial state doesn't seem to correspond to the actual state. I followed the demo in the docs and added some UI with help from lit/task, both in Chrome and Firefox the initial state after I open the page is “prompt” no matter if the permission was granted or denied.
I've got a reproduction repository (you can just run
npm run dev
) and also a github page with a demogps-permission-2024-07-24_22.29.10.mp4
and also my code inline here:
btw it doesn't seem to matter where or when the state is obtained.
I'm sorry if I misunderstood or misused something, thanks for the help :) and let me know if I can provide more details!
Edit: added a demo
The text was updated successfully, but these errors were encountered: