Skip to content
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

Remove table layout for chat messages (and fix layout issues yet again) #523

Merged
merged 2 commits into from
Apr 1, 2017

Conversation

maxpoulin64
Copy link
Member

@maxpoulin64 maxpoulin64 commented Jul 23, 2016

Fixes this:
capture d ecran_2016-07-22_22-04-49

back into this:
capture d ecran_2016-07-22_22-05-12

EDIT: So, this still had bugs, so I removed the table layout entirely. This one seems to just play nice now.

@maxpoulin64 maxpoulin64 added Type: Feature Tickets that describe a desired feature or PRs that add them to the project. second review needed labels Jul 23, 2016
@maxpoulin64 maxpoulin64 added this to the 2.0.0 milestone Jul 23, 2016
@maxpoulin64 maxpoulin64 changed the title Fix weird unneeded wrapping introduced by the unread marker Remove table layout for chat messages (and fix layout issues yet again) Jul 23, 2016
@maxpoulin64 maxpoulin64 force-pushed the PR/fix-msg-width branch 2 times, most recently from 5787c5b to e8f42ca Compare July 23, 2016 02:36
@astorije
Copy link
Member

I had played with removing the table layout for a bit, and after noticing so many bugs, I simply canceled. I need to test this PR thoroughly before we can merge or we'll do like we've been doing for a few weeks: one step forward, N steps backwards.

@astorije astorije self-assigned this Jul 23, 2016
@xPaw
Copy link
Member

xPaw commented Jul 23, 2016

Just wondering, what happens with very long names or notices? How do they overflow

@maxpoulin64
Copy link
Member Author

@xPaw: they wrap on multiple lines. Worse case they push the column for that one message, which is slighly uglier but has the advantage of not fucking up the whole table, so I think it's worth it anyway. I didn't change the wrapping code, so if there's something it probably was already there.

@astorije
Copy link
Member

which is slighly uglier but has the advantage of not fucking up the whole table, so I think it's worth it anyway.

Do you have any screenshot of this by any chance?

@maxpoulin64
Copy link
Member Author

which is slighly uglier but has the advantage of not fucking up the whole table, so I think it's worth it anyway.

Do you have any screenshot of this by any chance?

No, I haven't managed to trigger it yet. So far it seems like it does the same as it did with the table, the nick will just wrap on a second line. But if it were to happen, it would look a bit like this:

capture d ecran_2016-07-24_23-18-52

But it looks like this instead (but it also does on master):
capture d ecran_2016-07-24_23-20-19

I can also confirm long messages such as long links wrap properly and don't overflow.

@williamboman
Copy link
Member

screenshot 2016-08-07 at 16 37 28

Looks like this messes up existing border color on non-default themes (tested only on Zenburn).

@xPaw
Copy link
Member

xPaw commented Aug 20, 2016

What about using flexbox instead of floats? The textarea already does.

@astorije
Copy link
Member

Just curious, why removing the (CSS) table layout? I didn't know much about the use cases for this but it looks like it matches our goal fairly well, no?

@maxpoulin64
Copy link
Member Author

maxpoulin64 commented Sep 4, 2016

@astorije because it keeps exploding, especially with the unread marker? See the screenshot in the first post and try to tell me this is normal, expected layout for it. It's horrible.

Good point for the flexbox, will definitely go with that option.

@maxpoulin64
Copy link
Member Author

Updated to flexbox

@AlMcKinlay
Copy link
Member

I'm going to stick this PR on my running version and see how it works over the next few days. That's how I found all of the bugs in @astorije's one. But this looks promising, that's for sure.

@astorije
Copy link
Member

astorije commented Sep 6, 2016

That's how I found all of the bugs in @astorije's one.

🔪💔😭 ... 😄

See the screenshot in the first post and try to tell me this is normal, expected layout for it. It's horrible.

Agreed, that's gross.
I'll test this as well. Would be pretty awesome if we can get this sh*t behind us once and for all!

@maxpoulin64
Copy link
Member Author

That's how I found all of the bugs in @astorije's one.

That's how I test mines 😛 Not uncommon that I do a bunch of updates after opening the PR

@AlMcKinlay
Copy link
Member

Found my first bug.

Copy a line on the chat
Paste it into the textarea
You get 3 lines: the time on 1, the username on the next, and the message on the final one.

@astorije
Copy link
Member

astorije commented Sep 7, 2016

Is that a big bug though?
Worst case, can we intercept the copy to put them back into one line? It feels hackish but I don't think there is another option. More importantly, it could let us improve the copy and paste experience, such as wrapping nick with <> and padding the nicks when copying multiple lines.

@AlMcKinlay
Copy link
Member

AlMcKinlay commented Sep 7, 2016

Is that a big bug though?

It's big enough that I wouldn't be ok with 👍 this while it still exists.

can we intercept the copy to put them back into one line

That would be an acceptable solution, yeah. I had thought about doing this for exactly what you suggested at some point, but never did it.

What I would really like to figure out is why is it putting in newlines in the first place?

@astorije
Copy link
Member

astorije commented Sep 7, 2016

What I would really like to figure out is why is it putting in newlines in the first place?

Most likely because of this switch. Again, I don't think there is anything we can do without breaking the layout again. Maybe try with inline-block?

That would be an acceptable solution, yeah.

Right, but definitely for another PR.

@astorije
Copy link
Member

@maxpoulin64, given @YaManicKill's last comment and the fact that the 2.0.0 issue list is never ending (we have had 8-12 open issues/PRs there forever now...), do you think we could move that to the next release?
Current master works fine for v2.0.0 I think. Definitely looking forward to extensively test this once the 2.0.0 list is empty though.

@astorije astorije added the Meta: Do Not Merge This PR should not be merged. label Sep 18, 2016
Copy link
Member

@astorije astorije left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff, @maxpoulin64!!
Only a few things I believe, some questions to be answered and one small thing I noticed (that margin: auto; thingy) but hopefully this is going to be the end of an era of bugs!

I also think that all the word-wrap and word-break and overflow: hidden we put all over the place to counter the effects of the table layout are going to be needed anymore. Wanna take a stab at looking at which ones can be removed?

padding: 10px 0;
}

#chat .msg {
word-wrap: break-word;
word-break: break-word; /* Webkit-specific */
display: flex;
overflow: hidden;
position: relative;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not figure out why these last 2 lines (overflow: hidden; and position: relative;) are necessary. It seems like disabling them doesn't do anything for me.
Do you remember, by any chance?

}

#chat .time {
color: #ddd;
text-align: right;
max-width: 46px;
min-width: 46px;
width: 46px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember I had to set these 2 explicitly, but I can't remember why specifically: 8118d56#diff-97db1f70168fb5f12457b238ff6052b5L771

Chances are, this was table-layout-specific anyway...

}

#chat .from {
border-right: 1px solid #f6f6f6;
color: #b1c3ce;
padding-right: 10px;
text-align: right;
max-width: 134px;
min-width: 134px;
width: 134px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, :shrug_emoji:
3cddbbc#diff-97db1f70168fb5f12457b238ff6052b5L754

I guess this is why we should really add some comments to our code...

max-width: 134px;
min-width: 134px;
width: 134px;
align-self: stretch;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't seem to see a change when I enable/disable this. Remember why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://css-tricks.com/snippets/css/a-guide-to-flexbox/, stretch is the default value of align-items, and align-self is used to override it. Since this is not using align-items, there is nothing to override. Removing.


#chat .text {
margin: auto;
overflow: hidden;
Copy link
Member

@astorije astorije Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is unnecessary as it is shadowed by L907/R907 anyway.
Actually, that whole block seems unnecessary with this flexbox layout now:

 #chat .msg.motd .text,
 #chat .msg.message .text,
 #chat .msg.action .action-text,
 #chat .msg.notice .text {
    white-space: pre-wrap;
    overflow: hidden;
 }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playing with this more, I can't trigger something that needs it (at least on Chrome). Removing both.

}

#chat .text {
margin: auto;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the specific reason for this, but this is adding a top margin when text is one line but "from" goes over multiple lines. Example:

margin: auto; margin: auto;
screen shot 2016-09-20 at 00 41 59 screen shot 2016-09-20 at 00 42 42

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been trying to fix this and none of align-items: flex-start;, align-content: flex-start; or self-align: flex-start; did the trick.
I guess I'll just remove margin: auto unless someone has reasons to believe this is going to break something else.

padding: 10px 0;
}

#chat .msg {
word-wrap: break-word;
word-break: break-word; /* Webkit-specific */
display: flex;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gilles123 found out that these still need prefixing for now: #624 (comment)
Mind adding them to this PR please? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with autoprefixer and #609 this could be done magically behind the scenes :)

@nornagon
Copy link
Contributor

FYI, not directly related to this PR but still relevant: with flex-direction: column-reverse on the message list, we can almost entirely drop the stickyscroll jQuery plugin. column-reverse changes the way scrolling behaves when the DOM changes to consider the bottom of the element the "sticky" part, so adding a new message automatically scrolls the div down—no JS required! You still need a little JS (~a few lines) to keep the scroll position stuck if a message is added while you're scrolled up, but it's much simpler.

nornagon/lounge@react...nornagon:react-chat#diff-97db1f70168fb5f12457b238ff6052b5R768 if you're curious.

@astorije astorije removed the Meta: Do Not Merge This PR should not be merged. label Sep 25, 2016
@xPaw
Copy link
Member

xPaw commented Sep 25, 2016

@nornagon That makes selecting messages weird. And copying the messages makes them backwards.

@nornagon
Copy link
Contributor

@xPaw oh huh, i missed that! weird, that seems like a bug :/

@xPaw
Copy link
Member

xPaw commented Oct 1, 2016

To change how nicks overflow (instead of jumping to new line, extend it to right, this CSS needs to be added:

#chat .from {
    padding-left: 10px;
    min-width: 134px;
}

@astorije
Copy link
Member

astorije commented Oct 11, 2016

@maxpoulin64, I know you're locally running an older version of that PR, before you moved to flexbox. Do you mind updating your instance to run the latest version, so it lives in prod somewhere before merging?

I'd love to ship this, but we need to make sure the issues highlighted above are fixed beforehand.

@astorije
Copy link
Member

astorije commented Dec 9, 2016

@maxpoulin64, any chance you could be giving another stab at this?

@xPaw
Copy link
Member

xPaw commented Dec 10, 2016

@astorije can you take this over?

@astorije
Copy link
Member

@astorije can you take this over?

Will do. Do you have a list of requirements you think are important for this on the top of your head?

@xPaw
Copy link
Member

xPaw commented Dec 11, 2016

@astorije just the stuff me and you pointed out.

@astorije
Copy link
Member

This PR was 370 commits behind 😱

I have rebased it and I'm quickly testing it, but if someone (@thelounge/maintainers? @williamboman? @MaxLeiter?) would like to give it a try by merging it on their prod instance to have it run over multiple days, that would be very useful.

In general, does it seem like a good idea to switch from a CSS table layout (this is not evil, calm down 😅) to flexbox? What do we gain and lose?

@williamboman
Copy link
Member

williamboman commented Mar 29, 2017

I've run this on and off multiple times since it was opened, never ran into issues with it (other than it breaking other PRs such as #759). LGTM

@astorije
Copy link
Member

@YaManicKill, @williamboman, I have made a couple changes and rebased with master. Do you mind testing this a bit on your instances? Thanks!

Copy link
Member

@astorije astorije left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on the channel with @xPaw, let's get this merged and deal with the fallout post-merge until we cut a release.
8 months to merge this, sorry @maxpoulin64 😅

@astorije astorije merged commit 953325a into master Apr 1, 2017
@astorije astorije deleted the PR/fix-msg-width branch April 1, 2017 06:40
matburnham pushed a commit to matburnham/lounge that referenced this pull request Sep 6, 2017
Remove table layout for chat messages (and fix layout issues yet again)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Tickets that describe a desired feature or PRs that add them to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants