Skip to content

Commit

Permalink
fix bottom message hidden behind composer with minimised keyboard whe…
Browse files Browse the repository at this point in the history
…n replying to message (#20371)
  • Loading branch information
Parveshdhull committed Jun 13, 2024
1 parent df939bf commit 5f7d725
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/status_im/contexts/chat/messenger/composer/edit/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[utils.re-frame :as rf]))

(defn edit-message
[{:keys [text-value input-ref]}]
[{:keys [text-value input-ref input-height]}]
(let [theme (quo.theme/use-theme)]
[rn/view
{:style style/container
Expand All @@ -32,7 +32,7 @@
{:size 24
:icon-only? true
:accessibility-label :edit-cancel-button
:on-press #(utils/cancel-edit-message text-value input-ref)
:on-press #(utils/cancel-edit-message text-value input-ref input-height)
:type :outline}
:i/close]]))

Expand Down
8 changes: 6 additions & 2 deletions src/status_im/contexts/chat/messenger/composer/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@
(rf/dispatch [:chat.ui/cancel-message-reply]))

(defn cancel-edit-message
[text-value input-ref]
[text-value input-ref input-height]
(reset! text-value "")
;; NOTE: adding a timeout to assure the input is blurred on the next tick
;; after the `text-value` was cleared. Otherwise the height will be calculated
;; with the old `text-value`, leading to wrong composer height after blur.
(js/setTimeout #(blur-input input-ref) 100)
(js/setTimeout
(fn []
(blur-input input-ref)
(reanimated/set-shared-value input-height constants/input-height))
100)
(.setNativeProps ^js @input-ref (clj->js {:text ""}))
(rf/dispatch [:chat.ui/set-input-content-height constants/input-height])
(rf/dispatch [:chat.ui/cancel-message-edit]))
Expand Down
5 changes: 3 additions & 2 deletions src/status_im/contexts/chat/messenger/composer/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@
[:<>
[reply/view state (:input-ref props)]
[edit/view
{:text-value (:text-value state)
:input-ref (:input-ref props)}]]
{:text-value (:text-value state)
:input-height (:height animations)
:input-ref (:input-ref props)}]]
[reanimated/touchable-opacity
{:active-opacity 1
:on-press (fn []
Expand Down
45 changes: 35 additions & 10 deletions src/status_im/contexts/chat/messenger/messages/list/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,43 @@
;; https://github.com/status-im/status-mobile/issues/17426
[quo/skeleton-list (skeleton-list-props :messages parent-height platform/ios?)]]))

(defn header-height
[{:keys [insets able-to-send-message? images reply edit link-previews? input-content-height]}]
(if able-to-send-message?
(cond-> composer.constants/composer-default-height
(ff/enabled? ::ff/shell.jump-to)
(+ jump-to.constants/floating-shell-button-height)

(seq images)
(+ composer.constants/images-container-height)

reply
(+ composer.constants/reply-container-height)

edit
(+ composer.constants/edit-container-height)

link-previews?
(+ composer.constants/links-container-height)

(and input-content-height (not= input-content-height composer.constants/input-height))
(+ composer.constants/input-height)

true
(+ (:bottom insets)))
(- 70 (:bottom insets))))

(defn list-header
[insets able-to-send-message?]
(let [images (rf/sub [:chats/sending-image])
height (if able-to-send-message?
(+ composer.constants/composer-default-height
(if (ff/enabled? ::ff/shell.jump-to)
jump-to.constants/floating-shell-button-height
0)
(if (seq images) composer.constants/images-container-height 0)
(:bottom insets))
(- 70 (:bottom insets)))]
[rn/view {:style {:height height}}]))
(let [header-data {:insets insets
:able-to-send-message? able-to-send-message?
:input-content-height (:input-content-height (rf/sub [:chats/current-chat-input]))
:images (rf/sub [:chats/sending-image])
:reply (rf/sub [:chats/reply-message])
:edit (rf/sub [:chats/edit-message])
:link-previews? (or (rf/sub [:chats/link-previews?])
(rf/sub [:chats/status-link-previews?]))}]
[rn/view {:style {:height (header-height header-data)}}]))

(defn list-footer-avatar
[{:keys [distance-from-list-top display-name online? profile-picture theme group-chat color
Expand Down

0 comments on commit 5f7d725

Please sign in to comment.