This is slightly better code since it's based on the real available width instead of the contentItem width. (cherry picked from commit 1a69daf9)