-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Snackbar] Add support for multiline messages #4294
Conversation
@andrejunges Thanks for resubmitting. 👍 The mobile multi-line would be nice to have for the sake of completeness, but I don't think it's necessary for this PR. If someone really needs it, they can contribute separately. I'll let @oliviertassinari or one of the others comment on the approach. |
@andrejunges I submitted a PR to your fork that simplifies the example to use a single Snackbar. The current example allows two Snackbars to open at the same time. However, the new example code highlights a different issue. When the Snackbar opens, it takes the height of the previously open Snackbar, so a multiline that follows a single line is single line height. There also seems to be an animation glitch when multi-line exits. It stops after animating down what appears to be single-line height, before disappearing. (That was there before tihs change.) |
@andrejunges I'm not sure that the complexity of this implementation is worth it for the dynamic margin. There's also some other things here that should be unnecessary with flexbox, for eg, setting line-height at the root to 80px. |
@mbrookes Im out of good ideas at the moment to fix this issue - with this approach we have to define the
Regarding the animation issue I'd say all we need to do is check if its multiline in the @nathanmarks I can remove the line-height- I just let it there because I could be missing something.. I think that this way is much easier than setting the margins manually... do you think that doing it manually would be better? |
@@ -26,20 +26,25 @@ function getStyles(props, context) { | |||
} = context; | |||
|
|||
const isSmall = width === SMALL; | |||
const isMultiline = props.messageElement && props.messageElement.offsetHeight > 20; | |||
const rootHeight = isMultiline ? '80px' : `${desktopSubheaderHeight}px`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded to 80px
? Won't this just make it support 2 lines and not arbitrarily many lines?
@andrejunges Thanks for this second attempt to support multilines I think that it would be better to use a flexblox approach to get to correct layout. |
Why is that a concern? |
Basically, no matter the solution we are going to choose, we need to measure the layout height. |
so, you would like it to work based on margins / flex and a max-height value to limit it in two lines? @oliviertassinari |
@andrejunges Yes, we could rely on the margin / line-height to make sure the two lines cases is |
Just a question. |
@nehalbhanushali The height isn't supposed to be fixed. It's depending on the content that we render. |
@oliviertassinari Are you sure about that? #4294 (comment) |
@mbrookes What about the 118px height example? |
@oliviertassinari Alright clever-clogs. :) The point being, there are specific fixed heights defined for single and multi-line, rather than being variable based on content. Also, at some point we'd agreed that for relative simplicity, the 118px version wasn't strictly necessary for a multiline PR. |
on smaller screen i.e iphone 5 the text limit is very short before the action button stops showing. Any update on fix merge to master |
Why was this closed? Does anyone know of a workaround to be able to display large messages by chance? |
@andrejunges This was close as we migrated our effort toward the |
Ahhh, great! Thanks, just wanted to make sure this didn't get lost in ether. For folks who need bigger snackbar messages before next is ready this was the fix for me: attach this inline style to bodyStyle prop
|
@mbrookes @oliviertassinari
Second attempt to make the Snackbar support multiline text. 😄
I had some problems in that other branch and ended up creating it from the master.
A few notes:
SnackbarBody
is a functional component, I can't handle theref
there - so I pass the ref callback and the element itself from the parentSnackbar
. I know its not that pretty and I'm open to suggestions.messageProp
in the propTypes because the lint was complaining. Is that the correct way (using the @ignore)?Closes #3860