- {bottomNavItems.value.map((item) => (
-
-
-
{
+ const activeEl = document.activeElement;
+ const isInputFocused =
+ activeEl instanceof HTMLInputElement ||
+ activeEl instanceof HTMLTextAreaElement ||
+ activeEl?.getAttribute('contenteditable') === 'true';
+
+ let isViewportShrunk = false;
+
+ if (typeof window !== 'undefined' && window.visualViewport) {
+ isViewportShrunk =
+ window.innerHeight - window.visualViewport.height > 150;
+ }
+
+ isKeyboardOpen.value = isInputFocused || isViewportShrunk;
+ };
+
+ onMounted(() => {
+ if (typeof window === 'undefined') {
+ return;
+ }
+
+ window.addEventListener('focusin', checkFocus);
+ window.addEventListener('focusout', () => {
+ setTimeout(checkFocus, 100);
+ });
+
+ if (window.visualViewport) {
+ window.visualViewport.addEventListener('resize', checkFocus);
+ window.visualViewport.addEventListener('scroll', checkFocus);
+ }
+ });
+
+ onBeforeUnmount(() => {
+ if (typeof window === 'undefined') {
+ return;
+ }
+
+ window.removeEventListener('focusin', checkFocus);
+ window.removeEventListener('focusout', checkFocus);
+
+ if (window.visualViewport) {
+ window.visualViewport.removeEventListener('resize', checkFocus);
+ window.visualViewport.removeEventListener('scroll', checkFocus);
+ }
+ });
+
+ return () => {
+ if (isKeyboardOpen.value) {
+ return null;
+ }
+
+ return (
+
- );
+
+
+ {item.label}
+
+
+ ))}
+
+