Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-22757 Fix for date toast placement in web mobile view #5090

Merged
merged 8 commits into from
Mar 25, 2020

Conversation

sudheerDev
Copy link
Contributor

Summary

Push the toast by 50px when toast is present

Issue: FloatingTimestamp component need to know if any toasts are present in the UI. toasts state is only available in ToastWrapper as of now.

Solutions:

  1. Either use DOM manipulation like we do in few places of codebase and add a class when toast is present with add.classList
  2. Add a redux state to keep track of toast and use a selector
  3. Use something like ReactClone and get the required prop from ToastWrapper.
  4. We could have FloatingTimestamp in ToastWrapper

i went with 3 reasons being

  1. Really hacky and msot places we use in codebase tend to fail and cause regressions
  2. Feel like too much of work for such a small use case
  3. need to add couple more props to ToastWrapper so it can be passed to FloatingTimestamp

Ticket Link

Mar-20-2020 03-38-41
https://mattermost.atlassian.net/browse/MM-22757

@sudheerDev sudheerDev added the Work in Progress Not yet ready for review label Mar 19, 2020
@sudheerDev sudheerDev added this to the v5.22.0 milestone Mar 19, 2020
@sudheerDev
Copy link
Contributor Author

@nevyangelova @Willyfrog Let me know what you guys think. I am going to add tests after you guys have a look at it.

className += ' rhs';
}

return (
<div
className={className}
style={this.props.stylesOverride}
style={toastPresent ? {top: '50px'} : null}
Copy link
Contributor

Choose a reason for hiding this comment

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

0/5 maybe we can drive this by className.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i am not a fan of using classes if they are not reusable. It is hard to clean up with the amount of css we already have. I am gonna change to class though.

unreadToastProps = {
...unreadToastProps,
onDismiss: this.hideUnreadToast,
onClick: this.scrollToLatestMessages,
onClickMessage: Utils.localizeMessage('postlist.toast.scrollToBottom', 'Jump to recents'),
show: true,
showActions: !this.props.atLatestPost || (this.props.atLatestPost && !this.props.atBottom),
showActions: !atLatestPost || (atLatestPost && !atBottom),
Copy link
Contributor

Choose a reason for hiding this comment

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

1/5 can be simplified to !(atLatestPost && atBottom)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aah, Nice. i cannot wrap my head around conditions usually. Will change

Copy link
Contributor

@nevyangelova nevyangelova left a comment

Choose a reason for hiding this comment

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

Looks good though I like the solution 👍

Copy link
Contributor

@Willyfrog Willyfrog left a comment

Choose a reason for hiding this comment

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

So I think I’d have gone for #2 as it would allow for further usage if needed, not only for this view but for any other we might have. Having a way to know if the toast is present and probably some info with it, might be an easy way to share all the calculations already done for displaying on the toast.

With that said, this is an interesting approach, I didn’t know about react.clone, so that’s a new thing, but if it will always depends on the toast to be rendered, shouldn’t we pass the needed info to have the toast render it and remove cloning? Or are we planning to reuse the toast on other situations?

className += ' rhs';
}

return (
<div
className={className}
style={this.props.stylesOverride}
style={toastPresent ? {top: '50px'} : null}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don’t we use classname for this? We are already adding classes depending on what is around the floating timestamp, so another if wouldn’t hurt and it would probably be cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Classes already exist and there weren't part of the PR. As i said i am not a fan personally to use classes in out codebase anymore for things which are not reusable, or at least applied unconditionally. Things like these tend to make maintenance of css hard. There were some arguments in the past about performance of css vs inline styles in react but with the level of nesting we normally create the browsers will have a much harder time figuring out the specificity IMO.

In this case i am gonna change to class as it is popular behaviour and i am like 1/5 on this.

@sudheerDev
Copy link
Contributor Author

sudheerDev commented Mar 20, 2020

So I think I’d have gone for #2 as it would allow for further usage if needed, not only for this view but for any other we might have. Having a way to know if the toast is present and probably some info with it, might be an easy way to share all the calculations already done for displaying on the toast.

Ya, i think i am gonna change it to have a state in redux.

With that said, this is an interesting approach, I didn’t know about react.clone, so that’s a new thing, but if it will always depends on the toast to be rendered, shouldn’t we pass the needed info to have the toast render it and remove cloning? Or are we planning to reuse the toast on other situations?

The problem removing the cloning and passing in the props is that we need isMobile prop which means i need to add a state and a listener again in this component or pass that to ToastWrapper which only needs because of the FloatingTimestamp. Seemed like it has its own downsides.

@sudheerDev sudheerDev added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester CherryPick/Approved Meant for the quality or patch release tracked in the milestone and removed Work in Progress Not yet ready for review labels Mar 20, 2020
@sudheerDev
Copy link
Contributor Author

@Willyfrog @nevyangelova this is up for review.

Copy link
Contributor

@Willyfrog Willyfrog left a comment

Choose a reason for hiding this comment

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

lgtm, slight concern about naming but nothing too serious

Comment on lines +528 to +529
data: true,
type: 'UPDATE_TOAST_STATUS'
Copy link
Contributor

Choose a reason for hiding this comment

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

slightly concerned about the naming here: what should someone think of "update_toast_status=true"? maybe we should rename into something more descriptive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i am 0/5 on this but this is not something that people stumble up on when reading code IMO.

@sudheerDev
Copy link
Contributor Author

/update-branch

@mattermod
Copy link
Contributor

Error trying to update the PR.
Please do it manually.

@sudheerDev sudheerDev added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Mar 25, 2020
@sudheerDev sudheerDev added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Mar 25, 2020
@mattermod
Copy link
Contributor

Mattermost test server updated with git commit 7512c38861839dacd77bc752c55ae9f18e3b8819.

Access here: https://mattermost-webapp-pr-5090.test.mattermost.cloud

Copy link
Contributor

@jgilliam17 jgilliam17 left a comment

Choose a reason for hiding this comment

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

Thank you @sudheerDev
Tested, looks good to merge.

  • Verified date toast appears below unread/new message toast in mobile web view
  • There is an issue with the history toast missing, and will be filed separately

@jgilliam17 jgilliam17 added QA Review Done and removed 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Mar 25, 2020
@mattermod
Copy link
Contributor

Test server destroyed

@sudheerDev sudheerDev merged commit ff16e0e into mattermost:master Mar 25, 2020
@mattermod
Copy link
Contributor

@sudheerDev
Error trying doing the automated Cherry picking. Please do this manually

+++ Updating remotes...
Fetching upstream
Fetching origin
+++ Updating remotes done...
+++ Creating local branch automated-cherry-pick-of-#5090-upstream-release-5.22-1585161559
Branch 'automated-cherry-pick-of-#5090-upstream-release-5.22-1585161559' set up to track remote branch 'release-5.22' from 'upstream'.
+++ Downloading patch to /tmp/5090.patch (in case you need to do this again)

+++ About to attempt cherry pick of PR. To reattempt:
  $ git am -3 /tmp/5090.patch

Applying: MM-22757 Fix for date toast placement in web mobile view
Using index info to reconstruct a base tree...
M	components/post_view/post_list_virtualized/post_list_virtualized.jsx
M	components/toast_wrapper/toast_wrapper.jsx
Falling back to patching base and 3-way merge...
Auto-merging components/toast_wrapper/toast_wrapper.jsx
CONFLICT (content): Merge conflict in components/toast_wrapper/toast_wrapper.jsx
Auto-merging components/post_view/post_list_virtualized/post_list_virtualized.jsx
Patch failed at 0001 MM-22757 Fix for date toast placement in web mobile view
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

+++ Conflicts detected:

UU components/toast_wrapper/toast_wrapper.jsx

+++ Aborting in-progress git am.

+++ Returning you to the master branch and cleaning up.

sudheerDev added a commit that referenced this pull request Mar 25, 2020
* MM-22757 Fix for date toast placement in web mobile view

* Check if toast is present and push it down by 50px

* Rename func

* Change to dispatching an action on change of toast

* * Use className utility

* Fix for lint

* Fix tests after master merge

* Change default value in reducer
@sudheerDev sudheerDev deleted the MM-22757 branch March 25, 2020 18:41
@sudheerDev sudheerDev added CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone and removed CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Mar 25, 2020
@jgilliam17 jgilliam17 self-requested a review March 25, 2020 18:54
@jgilliam17
Copy link
Contributor

Please disregard all the label changes and a review re-request.
I misunderstood that history toast fix will be included in this PR and changed a bunch labels 😞

@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Mar 26, 2020
@jgilliam17 jgilliam17 added the Tests/Done Release tests have been written label Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone Docs/Not Needed Does not require documentation QA Review Done Tests/Done Release tests have been written
Projects
None yet
6 participants