Ionic modal breakpoints – Based on viewport or content height?

I’ve been working with Ionic’s modal component in a angular project and have witnessed some unexpected behavior regarding the breakpoints. According to the official documentation, modal breakpoints are supposed to be relative to the viewport height. But for some reason, in my project, it seems that the breakpoints are being applied relative to the content height inside the modal and not the viewport height.

Here is what I’m experiencing:

  • When I set breakpoints: [0.5, 0.75, 1] and initialBreakpoint: 0.5, the modal height is half the height of the modal’s content, not the viewport.
  • For example, if the content height is 373.5px, the modal height at a 0.5 breakpoint is around 186.75px, which is half of the content height.

Here is the relevant code setup:

TestPage Component Ts:

import { Component} from '@angular/core';
import { ModalController } from '@ionic/angular';

@Component({
  selector: 'app-test-page',
  templateUrl: './test-page.component.html',
  styleUrls: ['./test-page.component.css']
})
export class TestPageComponent {

  constructor(
    private modalController: ModalController
  ) {}
}

TestPage Component Html:

<div class="container">
    <h1>TESTING</h1>
    <h1>TESTING</h1>
    <h1>TESTING</h1>
    <h1>TESTING</h1>
</div>

TestPage Component Css:

  .container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 15px;
    box-sizing: border-box;
    height: 100%;
    width: 100%;
    background-color: #FEFEFA;
  }

I use a service to encapsulate the modal logic:

BottomsheetHelper Service:

@Injectable({
  providedIn: 'root'
})
export class BottomsheetHelperService {

  constructor(
    private modalController: ModalController
  ) { }

  async openTestPage(): Promise<void> {
    const modal = await this.modalController.create({
      component: TestPageComponent,
      handle: true,
      breakpoints: [0.5, 0.75, 1],
      initialBreakpoint: 0.5,
    });
    await modal.present();
  }
}

And in the parent component i call:

this.bottomSheetHelperService.openTestPage();

Screenshots of the modal and computed style from the console:

Questions:

  • Has anyone else encountered this behavior where the breakpoints are based on the content height instead of the viewport height?
  • Is this an expected behavior under certain conditions, or could it be due to some custom CSS or a specific version of Ionic?

I’m currently using Ionic version 8.2.6
I haven’t defined any global css style that would somehow override default behavior.

For my usecase, this is actually wanted behavior.
I want the modal/bottomsheet to set it self based on the content height. But i’m just curious to know if I can expect this to not work on a later time.

Thanks in advance for any insights!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật