Skip to content

Commit 5d3ae73

Browse files
committed
chore: debugging
1 parent 4b7f2fa commit 5d3ae73

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

core/src/components/modal/modal.tsx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
277277
@Listen('resize', { target: 'window' })
278278
onWindowResize() {
279279
// Update safe-area overrides for all modal types on resize
280+
console.log('[onWindowResize] calling updateSafeAreaOverrides');
280281
this.updateSafeAreaOverrides();
281282

282283
// Only handle view transition for iOS card modals when no custom animations are provided
@@ -666,6 +667,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
666667
}
667668

668669
// Now that animation is complete, update safe-area based on actual position
670+
console.log('[present animation complete] calling updateSafeAreaOverrides');
669671
this.updateSafeAreaOverrides();
670672

671673
// Initialize view transition listener for iOS card modals
@@ -877,8 +879,19 @@ export class Modal implements ComponentInterface, OverlayInterface {
877879
const isCardModal = presentingElement !== undefined;
878880
const isTablet = window.innerWidth >= 768;
879881

882+
console.log('[setInitialSafeAreaOverrides] called', {
883+
isSheetModal,
884+
isCardModal,
885+
isTablet,
886+
breakpoints: this.breakpoints,
887+
initialBreakpoint: this.initialBreakpoint,
888+
presentingElement: !!presentingElement,
889+
innerWidth: window.innerWidth,
890+
});
891+
880892
// Sheet modals: always touch bottom, top depends on breakpoint
881893
if (isSheetModal) {
894+
console.log('[setInitialSafeAreaOverrides] Sheet modal path - setting top/left/right to 0, leaving bottom alone');
882895
style.setProperty('--ion-safe-area-top', '0px');
883896
// Don't override bottom - sheet always touches bottom
884897
style.setProperty('--ion-safe-area-left', '0px');
@@ -888,6 +901,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
888901

889902
// Card modals are inset from edges (rounded corners), no safe areas needed
890903
if (isCardModal) {
904+
console.log('[setInitialSafeAreaOverrides] Card modal path - setting all to 0');
891905
style.setProperty('--ion-safe-area-top', '0px');
892906
style.setProperty('--ion-safe-area-bottom', '0px');
893907
style.setProperty('--ion-safe-area-left', '0px');
@@ -897,6 +911,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
897911

898912
// Phone modals are fullscreen, need all safe areas
899913
if (!isTablet) {
914+
console.log('[setInitialSafeAreaOverrides] Phone modal path - not setting any overrides');
900915
// Don't set any overrides - inherit from :root
901916
return;
902917
}
@@ -907,12 +922,16 @@ export class Modal implements ComponentInterface, OverlayInterface {
907922
const width = computedStyle.getPropertyValue('--width').trim();
908923
const height = computedStyle.getPropertyValue('--height').trim();
909924

925+
console.log('[setInitialSafeAreaOverrides] Tablet modal path', { width, height });
926+
910927
if (width === '100%' && height === '100%') {
928+
console.log('[setInitialSafeAreaOverrides] Fullscreen tablet modal - not setting overrides');
911929
// Fullscreen modal - need safe areas, don't override
912930
return;
913931
}
914932

915933
// Centered dialog - zero out all safe areas
934+
console.log('[setInitialSafeAreaOverrides] Centered tablet dialog - setting all to 0');
916935
style.setProperty('--ion-safe-area-top', '0px');
917936
style.setProperty('--ion-safe-area-bottom', '0px');
918937
style.setProperty('--ion-safe-area-left', '0px');
@@ -926,7 +945,10 @@ export class Modal implements ComponentInterface, OverlayInterface {
926945
*/
927946
private updateSafeAreaOverrides() {
928947
const wrapper = this.wrapperEl;
929-
if (!wrapper) return;
948+
if (!wrapper) {
949+
console.log('[updateSafeAreaOverrides] No wrapper element, returning early');
950+
return;
951+
}
930952

931953
const rect = wrapper.getBoundingClientRect();
932954
const threshold = 2; // Account for subpixel rendering
@@ -936,14 +958,44 @@ export class Modal implements ComponentInterface, OverlayInterface {
936958
const touchingLeft = rect.left <= threshold;
937959
const touchingRight = rect.right >= window.innerWidth - threshold;
938960

961+
console.log('[updateSafeAreaOverrides] called', {
962+
isSheetModal: this.isSheetModal,
963+
rect: { top: rect.top, bottom: rect.bottom, left: rect.left, right: rect.right },
964+
innerHeight: window.innerHeight,
965+
innerWidth: window.innerWidth,
966+
threshold,
967+
touchingTop,
968+
touchingBottom,
969+
touchingLeft,
970+
touchingRight,
971+
bottomCalc: `${rect.bottom} >= ${window.innerHeight - threshold} = ${touchingBottom}`,
972+
});
973+
939974
// Remove override when touching edge (allow inheritance), set to 0 when not touching
940975
const style = this.el.style;
976+
977+
const actions = {
978+
top: touchingTop ? 'removeProperty' : 'setProperty 0px',
979+
bottom: touchingBottom ? 'removeProperty' : 'setProperty 0px',
980+
left: touchingLeft ? 'removeProperty' : 'setProperty 0px',
981+
right: touchingRight ? 'removeProperty' : 'setProperty 0px',
982+
};
983+
console.log('[updateSafeAreaOverrides] actions:', actions);
984+
941985
touchingTop ? style.removeProperty('--ion-safe-area-top') : style.setProperty('--ion-safe-area-top', '0px');
942986
touchingBottom
943987
? style.removeProperty('--ion-safe-area-bottom')
944988
: style.setProperty('--ion-safe-area-bottom', '0px');
945989
touchingLeft ? style.removeProperty('--ion-safe-area-left') : style.setProperty('--ion-safe-area-left', '0px');
946990
touchingRight ? style.removeProperty('--ion-safe-area-right') : style.setProperty('--ion-safe-area-right', '0px');
991+
992+
// Log the actual style values after setting
993+
console.log('[updateSafeAreaOverrides] after setting, inline styles:', {
994+
top: style.getPropertyValue('--ion-safe-area-top'),
995+
bottom: style.getPropertyValue('--ion-safe-area-bottom'),
996+
left: style.getPropertyValue('--ion-safe-area-left'),
997+
right: style.getPropertyValue('--ion-safe-area-right'),
998+
});
947999
}
9481000

9491001
private sheetOnDismiss() {

0 commit comments

Comments
 (0)