Sencha Touch fieldset, title wrap to new line

Hello,

This is quick blog on one issue I faced recently. I was working on an application where I was having unwanted horizontal scroll bar while working with form panel and field sets. That was causing bit annoying effect for end user because when they try to scroll sometimes it scrolls horizontally sometime it scrolls vertically. After searching a lot I found that it was due to title of fieldset. When title goes beyond some characters it does not warp to next line but it increases the width of container and because of that horizontal scroll bar becomes visible. To prevent this I made following CSS changes.

If you check sencha touch debug css you will find following class in it.

.x-form-fieldset-title {
       text-shadow: white 0 1px 1px;
       color:  #333;
       margin: 1em 0.7em 0.3em;
       color:  #333;
       font-weight: bold;
       white-space: nowrap;
}

Check the last property white-space: nowrap; because of this it does not wrap to next line. So you need to override this class with following definition.

.x-form-fieldset-title {
       text-shadow: white 0 1px 1px;
       color:  #333;
       margin: 1em 0.7em 0.3em;
       color:  #333;
       font-weight: bold;
       white-space: normal;
}

You have to add this class in any CSS file which you load after sencha touch css and it will make the difference. This trick can also be applied for form panel labels.

Hope this helps you.

This entry was posted in Uncategorized on by .

About Hiren Dave

Hiren Dave is a software engineer, blogger and consultant with over 9 years of professional experience. He writes code in number of languages. Hiren has a passion for developing web apps, mobile apps and writing books and blog articles about programming. He has a solid experience of startups as he manages products for few startups. He is also passionate about researching and learning new technologies and trends. He has also authored a book Instant Sencha Touch, published by Packt and creator of Video Course "Beginning Laravel" for Packt

Leave a Reply

Your email address will not be published. Required fields are marked *