Skip to content

[Bug] Tab Label text-alignment/direction and overflow behavior doesn't match native tab bar #3881

@tcbbd

Description

@tcbbd

The overflow issue

When the tab label is too long, it fades out. Simple and elegant. But what if the tab label is in arabic? It turns out we must consider the text direction of tab label.

TST handles the overflow quite well if the browser language is LTR. But if we change the browser language to RTL, we get this:

Image

Notice that the native tab bar recognizes the text direction of tab label, and let the label fade naturally. But TST cannot do that. The fading effect changes according to text direction, but the text itself doesn't. It seems we need to set direction: ltr for overflowing LTR labels to match the native tab bar.

The general text alignment/direction issue

This is an off topic from #3869. In that post, I said that as we plan to change the position/alignment and possibly text direction of collapsed members counter, we may also want to consider the same thing for all other tab labels. After some investigation, I found that the native tab bar behaves this way:

  • If the browser language is LTR
    • RTL tab labels are set to rtl text direction, so the text aligns to right
  • If the browser language is RTL
    • LTR tab labels are not set to ltr text direction, so the text aligns to right
    • unless the tab label overflows, in which case it is set to ltr text direction, so that the fading looks natural.

When the browser language is LTR, TST only sets RTL tab labels to rtl text direction when they overflow. This doesn't match native tab bar. And when the browser language is RTL, we should set LTR tab group labels to ltr text direction, otherwise it looks ugly as shown in the screenshot.


In #3869, I got the idea that the tab label alignment can be designed to change according to sidebar side. A possible design could be like:

  • When sidebar style is left side, align all tab labels to left, whether it's LTR or RTL
  • When sidebar style is right side, align all tab labels to right, whether it's RTL or LTR
  • If the tab label overflows, set the text direction according to its content

But clearly, this does not match native tab bar behavior. If we want to match native tab bar in some sense, it could be like this:

  • When sidebar style is left side, we treat the tab labels as if the browser language is LTR
    • LTR labels align to left, RTL labels align to right
  • When sidebar style is right side, we treat the tab labels as if the browser language is RTL
    • LTR and RTL labels all align to right

This section should be viewed as a suggestion for Enhancement, rather than Bug. To pick which design is up to you. If both are not desired, then we should at least ensure that the tab labels always match native tab bar, no matter on which side the sidebar resides or in which language the browser is.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions