react-native-auto-positioned-popup 1.2.17 → 1.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import React, {ReactNode, createContext, useContext, useEffect, useMemo, useRef, useState} from 'react';
2
- import {Pressable, View, ViewStyle, Keyboard} from 'react-native';
2
+ import {Pressable, View, ViewStyle, Keyboard, StyleSheet} from 'react-native';
3
3
 
4
4
  // DEBUG FLAG: Set to false to disable all console logs for better performance
5
5
  const ROOTVIEW_DEBUG = false;
@@ -119,22 +119,33 @@ export const RootViewProvider: React.FC<RootViewProviderProps> = ({children}) =>
119
119
 
120
120
  return (
121
121
  <RootViewContext.Provider value={contextValue}>
122
- <>
122
+ {/* CRITICAL FIX: Use View with flex:1 instead of Fragment */}
123
+ {/* Fragment doesn't create actual View, causing absolute positioning to use wrong ancestor */}
124
+ {/* View with flex:1 ensures popup container positions relative to this full-screen View */}
125
+ <View style={rootViewStyles.container}>
123
126
  {children}
124
- {rootViews.map(
125
- ({id, style, component, useModal, onModalClose, centerDisplay}: DynamicViewBase): React.JSX.Element => {
126
- debugLog('react-native-auto-positioned-popup RootViewProvider rootViews.map=', {id, style, component, useModal, centerDisplay});
127
- return !useModal ? (
128
- <View
129
- key={id}
130
- ref={(r) => {
131
- if (r) viewRefs.current[id] = r;
132
- }}
133
- style={[style, {position: 'absolute'}]}
134
- >
135
- {component}
136
- </View>
137
- ) : (
127
+ {/* CRITICAL: Full-screen container ensures absolute positioning is relative to screen */}
128
+ {/* Without this, popup position may be offset by parent containers */}
129
+ {rootViews.length > 0 && (
130
+ <View
131
+ pointerEvents="box-none"
132
+ style={rootViewStyles.popupContainer}
133
+ >
134
+ {rootViews.map(
135
+ ({id, style, component, useModal, onModalClose, centerDisplay}: DynamicViewBase): React.JSX.Element => {
136
+ // POSITION DEBUG: Log the actual top value being applied (simple format for cleaner logs)
137
+ console.log(`📍 RENDER_STYLE id=${id} top=${style?.top} left=${style?.left} w=${style?.width} h=${style?.height} op=${style?.opacity}`);
138
+ return !useModal ? (
139
+ <View
140
+ key={id}
141
+ ref={(r) => {
142
+ if (r) viewRefs.current[id] = r;
143
+ }}
144
+ style={[style, {position: 'absolute'}]}
145
+ >
146
+ {component}
147
+ </View>
148
+ ) : (
138
149
  <Pressable
139
150
  key={id}
140
151
  style={[
@@ -180,11 +191,28 @@ export const RootViewProvider: React.FC<RootViewProviderProps> = ({children}) =>
180
191
  // >
181
192
  // </Modal>)
182
193
  }
194
+ )}
195
+ </View>
183
196
  )}
184
- </>
197
+ </View>
185
198
  </RootViewContext.Provider>
186
199
  );
187
200
  };
201
+
202
+ // Styles for RootView container - extracted for better performance
203
+ const rootViewStyles = StyleSheet.create({
204
+ container: {
205
+ flex: 1,
206
+ },
207
+ popupContainer: {
208
+ position: 'absolute',
209
+ top: 0,
210
+ left: 0,
211
+ right: 0,
212
+ bottom: 0,
213
+ zIndex: 99999,
214
+ },
215
+ });
188
216
  /*
189
217
  const { addRootView, updateRootView, removeRootView ,searchQuery } = useRootView();
190
218
  */