How to truncate long tex with flex parent having min-width:0 and flex grandparent having flex-wrap: wrap?

I want the blue text ( element) which is inside a flex item to get truncated with ellipsis (…) if text is too long. To do so I have to add min-width:0 to the parent (.entity-container). You can click Toggle element min-width to see how adding min-width:0 affects the code. It adds the ellipsis but it breaks also the flex-wrap: wrap property of .monitored-entities grandparent. In other words flex-wrap: wrap acts like flex-direction: row instead. How can I in the same time keep the blue text truncation with ellipsis and the flex-wrap: wrap property behaviour?

document.querySelector('button').addEventListener('click', 
  () => {
    [...document.querySelectorAll('.entity-container')]
    .map(item => item.style.minWidth != '' ? 
    item.style.minWidth = '' : 
    item.style.minWidth = 0)
  })
.monitored-entities {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
}
.entity-title {
  padding-top: 16px;
  padding-bottom: 16px;
  text-overflow: ellipsis;
  overflow: hidden;         
}
.entity-container {
  border-radius: 16px;
  border-style: solid;
  border-width: 1px;
  padding: 32px;
  margin: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: initial;
}
.entity-container > span {
  font-size: 30px;
  color: blue;
}
.entity-variables div {
  display: flex;
}
<div style='max-width: 400px'>
  <button>Toggle element min-width</button>
  <div class="monitored-entities">
    <div class="entity-container" style="">
      <span class="entity-title">host.webdata.replica.123456789.123456789.123456789</span>
      <div class='entity-variables'>
        <div><span class="variable-name"> health: </span><span>Bad</span></div>                                 
      </div>
    </div>  
    <div class="entity-container">
      <span class="entity-title">db.webdata.source</span>
      <div class='entity-variables'>
        <div><span class="variable-name"> health: </span><span>Good</span></div>                                    
      </div>
    </div>              
    <div class="entity-container">
      <span class="entity-title">db.webdata.replica</span>
      <div class='entity-variables'>
        <div><span class="variable-name"> health: </span><span>Bad</span></div>
      </div>
    </div>              
  </div>
</div>

min-width: 0 does not break the flex-wrap: wrap property of .monitored-entities. The issue you’re encountering is caused by nested flex containers, where the child container (.entity-variables div) lacks flex-wrap: wrap.

To fix this, you have two options:

  1. Remove the nested flex container (.entity-variables div).
  2. Add flex-wrap: wrap to the nested flex container to allow its content to wrap correctly.

Here’s how you can apply the second option:

document.querySelector('button').addEventListener('click',
  () => {
    [...document.querySelectorAll('.entity-container')]
      .map(item => item.style.minWidth != '' ?
        item.style.minWidth = '' :
        item.style.minWidth = 0)
  })
.monitored-entities {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
}
.entity-title {
  padding-top: 16px;
  padding-bottom: 16px;
  text-overflow: ellipsis;
  overflow: hidden;
}
.entity-container {
  border-radius: 16px;
  border-style: solid;
  border-width: 1px;
  padding: 32px;
  margin: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: initial;
}
.entity-container > span {
  font-size: 30px;
  color: blue;
}
.entity-variables div {
  display: flex;
  flex-wrap: wrap;
}
  <div style='max-width: 400px'>
    <button>Toggle element min-width</button>
    <div class="monitored-entities">
      <div class="entity-container">
        <span class="entity-title">host.webdata.replica.123456789.123456789.123456789</span>
        <div class='entity-variables'>
          <div><span class="variable-name"> health: </span><span>Bad</span></div>
        </div>
      </div>
      <div class="entity-container">
        <span class="entity-title">db.webdata.source</span>
        <div class='entity-variables'>
          <div><span class="variable-name"> health: </span><span>Good</span></div>
        </div>
      </div>
      <div class="entity-container">
        <span class="entity-title">db.webdata.replica</span>
        <div class='entity-variables'>
          <div><span class="variable-name"> health: </span><span>Bad</span></div>
        </div>
      </div>
    </div>
  </div>

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