-
Notifications
You must be signed in to change notification settings - Fork 196
[WIP] fix: set default numberOfLines prop to 1 in HeaderTitle #294
base: master
Are you sure you want to change the base?
[WIP] fix: set default numberOfLines prop to 1 in HeaderTitle #294
Conversation
we know the back button layout, so it'd be possible to set a horizontal margin of the same size. though imo truncating the title is bad. since title is for users to recognize what the screen is. truncating it prevents it. instead developers should ensure not to put anything that's too long in the title. |
@satya164 I'm using the header bar as a search bar, the user can write whatever he want and it will be displayed as the title, how should I handle this situation where the input isn't a fixed/known string? I don't think it's bad to truncate it in this scenario, the user would know what the full title is anyway because he wrote it. Besides that, a text that overlaps with the buttons or, even worse, overflows the screen won't be readable anyway. I would prefer it to be truncated and just see the dots. By the way, if there's an input in the header it should hide the first letters to avoid overlapping, take WhatsApp or Telegram search as example. |
overflow is worse, but that doesn't mean that truncating isn't bad. design guidelines such as material guidelines specifically advise against it. if you know, title can be long, it's always possible to come up with a different design (e.g. large header which shrinks on scroll, title inside the screen etc.). regardless, handling this properly isn't even possible because of async APIs of React Native regarding layout measurement. you're always going to see a flicker before we can truncate it. it's not going to change until Fabric releases.
there are a lot of limitations regarding what can be done. it's impossible to automatically detect of there is an input or not. however, there are props we provide such as |
Thanks for the fast response @satya164.
I didn't mean that it should detect if there's an input, I was describing how it should behave in that situation. The problem is that all the elements of the header have an absolute position and no width (or max width), that's why they overlap. If I set a width to the title then it behave as what I consider is correct:
I don't really like to play with the width, even less when there's no |
They are using absolute position because it's impossible to achieve the desired layout using flexbox. We cannot set a width or max width for the same reason I mentioned, layout is async and you'll see a flicker. There are a lot of things that needs to be handled and I have spent a lot of time on it. We'd have handled it better if it was possible. It's not as simple as it looks.
I'm talking about adding horizontal margin, not width. We can add margins/width in the library, but it will have a flicker and there's nothing we can do about it. It's easier to add a width/margin for you because you can hardcode values depending on your app. Whether you like it or not, it will provide the best UX. |
I understand, thanks for taking the time to discuss it! |
Description
I added back default numberOfLines prop to the HeaderTitle Component. It will truncate the default title text. [#290]
This PR would not fix the above issue, because HeaderTitle still overlaps on the headerLeft and/or headerRight.
Next steps
I'm not sure how you would like to handle positioning in the Header Component if text is long (overlaps).