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

[#21436] List of users overlap composer input #21641

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

ulisesmac
Copy link
Contributor

fixes #21436

Summary

This PR fixes the styles so that the input is no longer covered.

While solving this, I noticed we were updating the mention's state asynchronously, and it looked as follows:

bug.mp4

Screenshots (to check how the mentions are aligned):

-> -> -> ->

Not it's been fixed and looks as follows:

solved.mp4

Review notes

Testing notes

Platforms

  • Android
  • iOS

Steps to test

  • Open Status
  • Create a group chat with multiple participants
  • Clean the chat history
  • Try to tag someone (now it works without overlapping the content)

status: ready

Comment on lines +233 to +229
:style {:height "100%"
:background-color (colors/theme-colors colors/white
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the layout fix for the reported issue

Comment on lines 7 to 14
(defn- add-shadow
[theme styles]
(cond-> styles
platform/ios? (assoc :shadow-radius (colors/theme-colors 30 50 theme)
:shadow-opacity (colors/theme-colors 0.1 0.7 theme)
:shadow-color colors/neutral-100
:shadow-offset {:width 0 :height (colors/theme-colors 8 12 theme)})
:else (assoc :elevation 10)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified this to use assoc instead of merge 👀

Copy link
Contributor

Choose a reason for hiding this comment

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

Here I think cond-> is more convoluted to read than a simple if macro.

(defn- add-shadow
  [theme styles]
  (if platform/ios?
    (assoc styles
           :shadow-radius  (colors/theme-colors 30 50 theme)
           :shadow-opacity (colors/theme-colors 0.1 0.7 theme)
           :shadow-color   colors/neutral-100
           :shadow-offset  {:width 0 :height (colors/theme-colors 8 12 theme)})
    (assoc styles :elevation 10)))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha 😅 I completely agree! I'll update it 👍 Thanks

Comment on lines 28 to +39
(defn container
[opacity top theme]
(reanimated/apply-animations-to-style
{:opacity opacity}
(merge
{:position :absolute
:top (- (+ 8 top))
:left 8
:right 8
:border-radius 16
:z-index 4
:max-height constants/mentions-max-height
:background-color (colors/theme-colors colors/white colors/neutral-95 theme)}
(shadow theme))))
[{:opacity opacity}
(add-shadow theme
{:position :absolute
:top (- (+ 8 top))
:left 8
:right 8
:border-radius 16
:z-index 4
:max-height constants/mentions-max-height
:background-color (colors/theme-colors colors/white colors/neutral-95 theme)})])
Copy link
Contributor Author

@ulisesmac ulisesmac Nov 19, 2024

Choose a reason for hiding this comment

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

I tried several ways to solve the rendering issue in the mentions component, but nothing else worked.

The problem is caused by our apply-animations-to-style wrapper, seems its usage delays the rendering of its stytles ~1 frame.

By avoiding its usage, we get the component state updated on time, here we are using the vector syntax introduced a while ago.

CC: @ilmotta

@status-im-auto
Copy link
Member

status-im-auto commented Nov 19, 2024

Jenkins Builds

Click to see older builds (1)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a439f34 #2 2024-11-19 22:04:44 ~4 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ f916a62 #3 2024-11-19 22:09:32 ~4 min tests 📄log
✔️ f916a62 #3 2024-11-19 22:13:33 ~8 min android-e2e 🤖apk 📲
✔️ f916a62 #3 2024-11-19 22:13:45 ~8 min ios 📱ipa 📲
✔️ f916a62 #3 2024-11-19 22:13:56 ~9 min android 🤖apk 📲
✔️ dc532cd #4 2024-11-20 18:51:50 ~4 min tests 📄log
✔️ dc532cd #4 2024-11-20 18:55:45 ~8 min android-e2e 🤖apk 📲
✔️ dc532cd #4 2024-11-20 18:56:14 ~9 min android 🤖apk 📲
✔️ dc532cd #4 2024-11-20 18:58:31 ~11 min ios 📱ipa 📲

@ulisesmac ulisesmac force-pushed the 21436-list-of-users-overlap-input branch from f916a62 to dc532cd Compare November 20, 2024 18:46
Copy link
Contributor

@ilmotta ilmotta left a comment

Choose a reason for hiding this comment

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

Thanks for this important fix!

[rn/flat-list
[suggestions])
[reanimated/view {:style (style/container opacity top theme)}
[reanimated/flat-list
Copy link
Contributor

Choose a reason for hiding this comment

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

What do we gain by using a flat list here instead of the macro for? I checked with a simple for and it all works the same apparently, including the animation.

Related to your comment #21641 (comment), we should consider removing micro animation code in certain places if they get in our way during development at this stage of the product. I'm not saying we should always do that with micro animations. Here, you fought a battle related to state synchronization between two sources as you and I talked in private. This view component contains workarounds that make the code brittle.

The code below is much simpler and delivers the same experience in my opinion. Or perhaps my suggested code has a flaw, but I couldn't see.

(defn view
  [layout-height]
  (let [suggestions (rf/sub [:chat/mention-suggestions])
        theme       (quo.theme/use-theme)
        top         (min constants/mentions-max-height
                         (* (count suggestions) 56)
                         (- @layout-height
                            (+ (safe-area/get-top)
                               messages.constants/top-bar-height
                               5)))]
    [rn/view {:style (style/container top theme)}
     (for [user (vals suggestions)]
       ^{:key (:key user)}
       [mention-item user])]))

Anyway, this is just a light suggestion to remove the micro animation to simplify, but since you solved the problem it's okay to keep the animation @ulisesmac.

Copy link
Member

Choose a reason for hiding this comment

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

What do we gain by using a flat list here instead of the macro for? I checked with a simple for and it all works the same apparently, including the animation.

I think without the flatlist we wouldn't get the scroll if the list is large, but unsure if we want that. We could limit the amount of results we show also if we don't want the scroll, might make it lighter to re-render.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do we gain by using a flat list here instead of the macro for? I checked with a simple for and it all works the same apparently, including the animation.

@ilmotta A flat-list is lazy, it's built to render a lot of items, it just renders what you see (window-size) and some windows above and below (it's configurable). Having a for inside a scroll-view (to keep the scrolling) will render all possible suggestions at once. Not the best for this use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ilmotta
Thanks for your simplification. I think the opacity animation gives a slightly smoother experience, ofc, I'd like to improve the code by removing that use-effect, but I think we will need this hook in any animated component. Also, since the problem is solved I'd prefer to keep it.

We can explore ways to make this cleaner later, since in the future we will add animations to our app to make its usage more enjoyable.

Copy link
Contributor

Choose a reason for hiding this comment

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

The list of mentions is limited by 10 items I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

In which case the flatlist is unnecessary. #21131

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, then we can use a scrollview! I'll change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: CONTRIBUTOR
Development

Successfully merging this pull request may close these issues.

Dropdown list of users overlaps the message input field when mentioning a user in empty chat in community
4 participants