Describe the bug
In case, main button became visible or hidden, native app does not send viewport_changed event even in case, viewport really changed. On client side you should always track resize event and update current viewport data which seems implicit.
To Reproduce
It will be a bit harder for me to show how to reproduce this problem as long as I can't use libraries and examples I provided before because they already close this problem locally. The only thing I could help you here with is to provide minimal code HTML example which shows the problem:
<html>
<head>
<meta charset="UTF-8">
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/@twa.js/bridge@0.2.1"></script>
</head>
<body>
<script>
const {defineEventReceiver, postEvent} = window.TwaBridge;
// Define event receiver which will allow us to handle native app events.
defineEventReceiver();
// Add message event handler to display event received from native app.
window.addEventListener('message', e => {
if ('eventType' in e.detail) {
console.log('Received event:', e.detail);
}
});
// Log app height before showing main button.
console.log(window.innerHeight);
// Show main button.
postEvent('web_app_setup_main_button', {
is_visible: true,
is_active: true,
is_progress_visible: false,
text: 'TEXT',
color: '#ff0000',
text_color: '#ffffff',
});
// After some timeout show new app height.
setTimeout(() => {
console.log(window.innerHeight);
}, 1000);
</script>
</body>
</html>
To check if external events handling works correctly, you could press main button and see log message in console.
Expected behavior
Event viewport_changed is sent every time, its height or other parameters changed.
Describe the bug In case, main button became visible or hidden, native app does not send
viewport_changed
event even in case, viewport really changed. On client side you should always trackresize
event and update current viewport data which seems implicit.To Reproduce It will be a bit harder for me to show how to reproduce this problem as long as I can't use libraries and examples I provided before because they already close this problem locally. The only thing I could help you here with is to provide minimal code HTML example which shows the problem:
To check if external events handling works correctly, you could press main button and see log message in console.
Expected behavior Event
viewport_changed
is sent every time, its height or other parameters changed.