Skip to content

Issue 19051 - Suggestions list disappear after expanding/collapsing the reply input#19248

Merged
hassaanelgarem merged 16 commits intowordpress-mobile:trunkfrom
igoriols:feature/19051-keep-suggestions-list-visible
Sep 6, 2022
Merged

Issue 19051 - Suggestions list disappear after expanding/collapsing the reply input#19248
hassaanelgarem merged 16 commits intowordpress-mobile:trunkfrom
igoriols:feature/19051-keep-suggestions-list-visible

Conversation

@igoriols
Copy link
Contributor

@igoriols igoriols commented Aug 26, 2022

Closes #19051

Description

In this PR, I'm addressing the requested change to keep the suggestions list visible when expanding/collapsing the reply text field. If the user inserts a @ the suggestions appear. And if the user clicks on the ^ button, it should be visible when the text area is expanded. Following the same idea, if the text area is expanded and the suggestions list is visible, it should remain visible when the user clicks on the button.

Details

  • I created FullScreenCommentReplyViewModel to extract business logic from FullScreenCommentReplyViewController and make it easy to test the visibility of the suggestions list.

  • I added a new parameter on FullScreenCommentReplyViewController.enableSuggestions representing the last search string provided by the user, and it is being called before FullScreenCommentReplyViewController is presented.

  • I changed FullScreenCommentReplyViewController to display the suggestions list if the search text was provided. The suggestions list is shown or not in viewDidAppear using the search text provided. The suggestions list remains hidden if the search text is nil or empty.

  • I modified FullScreenCommentReplyViewController.onExitFullscreen to have one more string as the last parameter. It represents the last search text inserted by the user when the text input area is expanded.

  • When the user exits FullScreenCommentReplyViewController, onExitFullscreen completion block is called with the last search text provided. If the user press Reply there is no need to keep the list visible, so I'm sending nil in the completion block.

  • I created a new method in ReplyTextViewDelegate which is being called when FullScreenCommentReplyViewController is closed. The implementation receives the last search text provided by the user, and displays the suggestions list.

  • I'm calling the new delegate method on every view controller that calls FullScreenCommentReplyViewController enabling the suggestions list visibility. So, every view controller that conforms with willEnterFullScreen method is conforming with the new didExitFullScreen method.

Preview

Testing Instructions

N.B: The user-mentions suggestions feature is not enabled in self-hosted sites ( wordpress.org ).

Scenario 1 - Suggestions list remains visible when the text area is expanded

  1. Tap the "My Site" tab.
  2. Tap on "Menu".
  3. Tap on "Comments" row.
  4. Tap any comment.
  5. Tap "Reply" button.
  6. Type "@" and you should see the user-mentions suggestions list.
  7. Click on the ^ button.
  8. Check if the suggestions list remains visible.

Scenario 2 - Suggestions list remains visible when the text area is collapsed

  1. Tap the "My Site" tab.
  2. Tap on "Menu".
  3. Tap on "Comments" row.
  4. Tap any comment.
  5. Tap "Reply" button.
  6. Type "@" and you should see the user-mentions suggestions list.
  7. Click on the ^ button.
  8. Erase the text to make the suggestions list disappear.
  9. Make it appear again by typing "@".
  10. Click on the button to collapse the text area.
  11. Check if the suggestions list remains visible.

There are other scenarios to display the suggestions list described in #18979.

Regression Notes

  1. Potential unintended areas of impact
    Unfortunately I couldn't create unit tests for every view controller conforming with the new didExitFullScreen delegate method: CommentDetailViewController, NotificationDetailsViewController and ReaderCommentsViewController.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    I've manually tested all the scenarios where didExitFullScreen is called.

  3. What automated tests I added (or what prevented me from doing so)
    I added FullScreenCommentReplyViewModelTests and I added new tests in FullScreenCommentReplyViewControllerTests to check the visibility of the suggestions list.
    I couldn't add new tests for CommentDetailViewController, NotificationDetailsViewController and ReaderCommentsViewController to ensure the suggestions list is displayed because those view controllers are not unit-testable.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@hassaanelgarem
Copy link
Contributor

@igoriols The first time the input field is expanded, the issue is fixed. However, if I expand the list again the list disappears.

Simulator.Screen.Recording.-.iPhone.13.Pro.-.2022-08-29.at.02.26.44.mp4

@igoriols
Copy link
Contributor Author

igoriols commented Aug 29, 2022

@igoriols The first time the input field is expanded, the issue is fixed. However, if I expand the list again the list disappears.
Simulator.Screen.Recording.-.iPhone.13.Pro.-.2022-08-29.at.02.26.44.mp4

Sorry, but I couldn't reproduce the behavior you identified. Here is what I found:
Simulator Screen Recording - iPhone 13 Pro - 2022-08-29 at 09 03 31

Could you please share more details about how you identified what you have found?
How did you access the screen to reply to the comment?

Thanks in advance.

@hassaanelgarem
Copy link
Contributor

hassaanelgarem commented Aug 29, 2022

Could you please share more details about how you identified what you have found?

@igoriols Sure!

  1. Make sure to have a comment on a post with likes
  2. Install the app
  3. Go to the notifications tab
  4. Tap on "Someone liked your comment" notification
  5. Tap on the comment
  6. This opens up the comments view
  7. Type in the reply field "@" followed by any prefix
  8. Expand the reply field
  9. Collapse the reply field
  10. Expand the reply field
  11. Notice that the suggestions list is not visible

I think it's reproducible from any type of notification not just "Someone liked your comment"

@igoriols
Copy link
Contributor Author

igoriols commented Aug 29, 2022

Could you please share more details about how you identified what you have found?

@igoriols Sure!

1. Make sure to have a comment on a post with likes

2. Install the app

3. Go to the notifications tab

4. Tap on "Someone liked your comment" notification

5. Tap on the comment

6. This opens up the comments view

7. Type in the reply field "@" followed by any prefix

8. Expand the reply field

9. Collapse the reply field

10. Expand the reply field

11. Notice that the suggestions list is not visible

I think it's reproducible from any type of notification not just "Someone liked your comment"

Thank you for the detailed steps. Sorry, but I still can't reproduce it yet. 😕

Simulator Screen Recording - iPhone 13 Pro - 2022-08-29 at 14 30 34

I also tried to reproduce it with other types of notifications, but I couldn't reproduce it yet. The new method I created is being called every time the suggestions list visibility is enabled. So, it should work by expanding/collapsing the reply field.

One thing I noticed is that sometimes the UI hangs during the search. Maybe a possible solution is to extract the search execution to another thread.

The behavior you found is always happening?
Could you please check it again?

Copy link
Contributor

@hassaanelgarem hassaanelgarem left a comment

Choose a reason for hiding this comment

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

The behavior you found is always happening?
Could you please check it again?

I tested again on a physical device and the issue is not happening. Looks like a simulator bug 🤦‍♂️

// Static margin between the suggestions view and the text cursor position
private let suggestionViewMargin: CGFloat = 5

var viewModel: FullScreenCommentReplyViewModelType = FullScreenCommentReplyViewModel()
Copy link
Contributor

Choose a reason for hiding this comment

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

[Nit] I don't think this variable should be public. How about injecting it through an initializer?

Copy link
Contributor Author

@igoriols igoriols Aug 31, 2022

Choose a reason for hiding this comment

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

Good idea, I thought about injecting through an initializer at first, but as it was inheriting from an Objective-C class, I thought it would be more complex. After a deeper look, I realized it was easier than I thought.
Thanks for suggesting it.

XCTAssertNotNil(tableView)
}

func testShouldShowSuggestionsIsFalse() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is a bit vague. Can you either add a more verbose setup in the test or add some documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I added a more verbose setup. Is it ok like that?

Copy link
Contributor

@hassaanelgarem hassaanelgarem Aug 31, 2022

Choose a reason for hiding this comment

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

It's still unclear to me why the expected result is false 🤔

Copy link
Contributor Author

@igoriols igoriols Aug 31, 2022

Choose a reason for hiding this comment

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

It runs on the test environment with the mocked CoreData context, so it is expected to return false. I will add some documentation and one more test to clarify.

XCTAssertNotNil(tableView)
}

func testShouldShowSuggestionsIsFalse() {
Copy link
Contributor

@hassaanelgarem hassaanelgarem Aug 31, 2022

Choose a reason for hiding this comment

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

It's still unclear to me why the expected result is false 🤔

Comment on lines +41 to +44
// nibName from super class
let nibName = String(describing: EditCommentViewController.self)
self.viewModel = viewModel
super.init(nibName: nibName, bundle: nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

[Nit]
EditCommentViewController has a static function (+ (NSString *)nibName;) that determines the nibName that we can leverage. If we make this public we can do something like this:

Suggested change
// nibName from super class
let nibName = String(describing: EditCommentViewController.self)
self.viewModel = viewModel
super.init(nibName: nibName, bundle: nil)
self.viewModel = viewModel
super.init(nibName: Self.nibName(), bundle: nil)

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. I applied your suggestions. Thank you!

@hassaanelgarem
Copy link
Contributor

LGTM!
One last thing, please add a low-priority release note for this fix 🙏

@hassaanelgarem hassaanelgarem modified the milestones: 20.7, 20.8 Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestions list (using @-mention) disappear after expanding/collapsing the reply input

2 participants