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

autocomplete: Put best matches near input field. #1131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

apoorvapendse
Copy link
Contributor

@apoorvapendse apoorvapendse commented Dec 11, 2024

This commit reverses the list that was originally
presented to the user while showing the typeahead
menu.

This makes sense since on mobile its easier to click on options closer to the input box, i.e. where your fingers are currently present, instead of pressing arrow keys to navigate through the options on a keyboard which is convenient on a desktop setup.

Hence we place the best matching options not at the top of the typeahead menu, but instead at the bottom for better reachability and convenience of the user.

CZO

Fixes #1121.

Here is a demo:
Screencast from 12-11-2024 12:38:19 PM.webm

image
image

@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch 3 times, most recently from a146a49 to bd3a205 Compare December 16, 2024 02:00
Copy link
Member

@PIG208 PIG208 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 the PR @apoorvapendse! Left some comment.

This doesn't fix #1123 because the emoji picker (added in #1103) is a feature separate from autocompletion, so please update the PR comment and the commit message to reflect that.

test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from bd3a205 to 129434b Compare December 18, 2024 03:04
@apoorvapendse
Copy link
Contributor Author

Hey @PIG208, thanks for reviewing the PR.
I've updated it and hope it meets your expectations.
Could you please elaborate on what kind of comment is expected as per this comment
Thanks.

@apoorvapendse apoorvapendse requested a review from PIG208 December 18, 2024 03:16
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from 129434b to b35ddbf Compare December 18, 2024 03:18
@PIG208 PIG208 self-assigned this Dec 18, 2024
@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Dec 18, 2024
@apoorvapendse
Copy link
Contributor Author

@PIG208 thank you for clarifying ,
I don't think this is affected by #226, since the default behavior on CZO also requires you to enter :<some text> in order to trigger the emoji typehead.

Open to your feedback.
Thank you.

@apoorvapendse apoorvapendse requested a review from PIG208 December 19, 2024 02:17
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from b35ddbf to df05da4 Compare December 19, 2024 17:28
@apoorvapendse
Copy link
Contributor Author

Hey @PIG208,
I am sorry, did you mean to mention #226 instead of #227 in this comment.

I added a comment mentioning that dependency here in the latest commit.

Is that what was expected?

@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from df05da4 to 5ae02ae Compare December 19, 2024 17:33
Copy link
Member

@PIG208 PIG208 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 the update! Left some more comments. I read the first test and skimmed the second one. It looks like the current approach of getting scroll offset is not working properly.

For the next revision, please do a round of self-review addressing the style issues mentioned in the comments, and apply it to other places as well.

test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch 3 times, most recently from 95f971d to 2f522f5 Compare December 20, 2024 02:06
@apoorvapendse
Copy link
Contributor Author

apoorvapendse commented Dec 20, 2024

Change Summary for @PIG208

  • Replaced pumpAndSettle with pump
  • Addressed your concern regarding the removal of scrolling in the opposite direction.
  • Addressed your concern regarding the usefullness of scrolling.
    Replaced comparing listViewFinder.dy with comparing the y position of the first emoji & mention in case of negative y offset.
    See CZO topic I created for more details.
  • Removed ListViewFinder render checks as suggested.
  • Moved ListViewFinder initialization before initialScrollOffset as suggested.
  • Wrapped the end parens as mentioned.
  • Broke the check statements into multiple lines as per this input.
  • Removed the redundant check(because:'Each user option should be rendered (index: $i)',finder).findsOne(); as suggested.
  • Addressed other long line check statements.
  • Removed expectedUserSequence and used users instead.
  • Fixed other spacing issues.

Thank you for being patient.
I believe this PR is ready for another review.

@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch 4 times, most recently from e2bd10c to cd4226e Compare December 20, 2024 03:24
@PIG208 PIG208 self-requested a review December 23, 2024 17:23
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from cd4226e to 1b8cf39 Compare December 24, 2024 02:01
@apoorvapendse
Copy link
Contributor Author

apoorvapendse commented Dec 24, 2024

Sorry for responding so late @PIG208 .
GitHub didn't send me any emails about your replies.

I've fixed the for loop formatting here, here and here.

Copy link
Member

@PIG208 PIG208 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 the update! I revised the @-mentions test as an example of what we usually expect for testing. Please read it and try to apply the same approach to the similar test for emojis.

test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from 3a19206 to dc1a5eb Compare December 27, 2024 02:06
@apoorvapendse apoorvapendse requested a review from PIG208 December 27, 2024 02:07
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch 2 times, most recently from c1ac550 to 08f9b96 Compare December 27, 2024 02:09
@apoorvapendse
Copy link
Contributor Author

Hi, @PIG208.
Kindly TAL when you find the time.
I've written a summary for my changes.
source.

Copy link
Member

@PIG208 PIG208 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 the update. I think the test for emojis needs to be more concise. Maybe try to follow the other one closer as they are testing the same aspect of autocompletion but in different contexts.


final positions = emojiSequence.take(8).map((icon) {
final finder = find.text(icon);
check(because:"Each emoji option should be rendered", finder).findsOne();
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the because for this check. findsOne should be evident that we expect the option to be rendered.

await tester.pump();
final firstEmojiPositionAfterScrollDown = tester.getTopLeft(find.text(emojiSequence[0])).dy;
check(
because:"ListView options should not scroll down further than initial position",
Copy link
Member

Choose a reason for hiding this comment

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

There is still the spacing issue — there should be a space here because: "..."


check(
because: "The last emoji should not be visible before scrolling up"
,find.text(emojiSequence.last)
Copy link
Member

Choose a reason for hiding this comment

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

Usually we don't start lines with ,. Format list of arguments using trailing commas instead.

final positions = emojiSequence.take(8).map((icon) {
final finder = find.text(icon);
check(because:"Each emoji option should be rendered", finder).findsOne();
return tester.getTopLeft(finder).dy;
Copy link
Member

Choose a reason for hiding this comment

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

We only need the position of the first element, so this map can be simplified, similar to the other test case added.

@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch 5 times, most recently from 632c295 to 13c33b2 Compare January 9, 2025 06:18
@apoorvapendse
Copy link
Contributor Author

apoorvapendse commented Jan 9, 2025

Change Summary for @PIG208

Updates

  1. Replaced mapping over emoji seq to generate positions list with inital position of the first emoji that satisfies the suggestions set by this and this condition and is similar to the test you wrote and follows this suggestion of yours.

  2. Used trailing comma here as pointed here.

  3. Fixed spacing issue here as suggested here.

Blockers

No blockers, thanks to your detailed feedback.

Review request

I have addressed all the 4 comments made in the recent review.
And would be happy to get another review when you find it convenient.

Copy link
Member

@PIG208 PIG208 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 the update! Left some more comments.

await tester.enterText(composeInputFinder, 'hi :z');
await tester.pump();

final firstEmojiInitialPosition = tester.getTopLeft(find.text(emojiSequence[0]),warnIfMissed: true).dy;
Copy link
Member

@PIG208 PIG208 Jan 9, 2025

Choose a reason for hiding this comment

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

true is already the default value, so we can omit warnIfMissed: true here.

Copy link
Member

Choose a reason for hiding this comment

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

I see that you removed the emojiSequence.take(8).map altogether. We do still need the check for (icon) => find.text(icon).findsOne(), (and additionally a find.text(emojiSequence.last)).findsNothing(), moving the check from line 320 to here should work).

Having all these check help the reader understand that only the first few options are initially visible, so it makes sense to check again later after scrolling the list. See the other test for reference, as they are quite similar.

await tester.pump();

check(because: "The biohazard emoji should be visible after scrolling up",
find.text(emojiSequence.last)).findsOne();
Copy link
Member

Choose a reason for hiding this comment

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

nit: indentation

This find is a part of the check and should be indented.


final firstEmojiPositionAfterScrollUp = tester.getTopLeft(find.text(emojiSequence[0])).dy;
check(because: "Scrolling up should reveal other emoji matches",
firstEmojiPositionAfterScrollUp).isGreaterOrEqual(firstEmojiInitialPosition);
Copy link
Member

Choose a reason for hiding this comment

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

nit: similar indentation issue here too

firstEmojiPositionAfterScrollUp).isGreaterOrEqual(firstEmojiInitialPosition);

debugNetworkImageHttpClientProvider = null;

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove extra newline

@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from 13c33b2 to 35f9a10 Compare January 10, 2025 08:40
@apoorvapendse
Copy link
Contributor Author

I've done the changes mentioned @PIG208.
Please take a look at your convenience.

Thank you for being patient.

Copy link
Member

@PIG208 PIG208 left a comment

Choose a reason for hiding this comment

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

Commit message nit:

Tests have been added to verify the
emoji and mention render behavior.

Normally we include tests whenever there is behavior change, so we can remove this paragraph.

Co-authored-by: Zixuan James Li <[email protected]>
Fixes: https://github.com/zulip/zulip-flutter/issues/1121

should be:

Co-authored-by: Zixuan James Li <[email protected]>
Fixes: #1121

The lines started with Something: are conventionally placed at the end as an agreed upon metadata structure for commits; there is no strict rules on what types of metadata you can have, but usually they are in this form.

Left some comments, mostly nits.

final firstEmojiInitialPosition = tester.getTopLeft(find.text(emojiSequence[0])).dy;
final listViewFinder = find.byType(ListView);

emojiSequence.take(8).forEach((icon)=>check(because:"Each emoji option should be rendered",
Copy link
Member

Choose a reason for hiding this comment

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

Let's just remove the because: part as it is evident from the code what the check is for.

Copy link
Member

Choose a reason for hiding this comment

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

nit: formatting: (icon) => check(...)

Copy link
Member

Choose a reason for hiding this comment

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

Once we rename emojiSequence to emojiNames, we can rename icon to emojiName.

test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
find.text(emojiSequence.last)
).findsNothing();

// Scroll up
Copy link
Member

Choose a reason for hiding this comment

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

nit: this comment does not seem quite useful, as it just repeats the code below it

@apoorvapendse
Copy link
Contributor Author

I am unable to understand how you see the resolved link here.

This is the commit message I see on git log:

commit 64f4b77bf4812f97294ba10076a2cf36c6886ef7 (HEAD -> put-best-matches-near-fingers)
Author: Apoorva Pendse <[email protected]>
Date:   Wed Dec 11 19:35:54 2024 +0530

    autocomplete: Put best matches near input field.
    
    This commit reverses the list that was originally
    presented to the user while showing the typeahead menu.
    
    This makes sense since on mobile its easier to click
    on options closer to the input box, i.e.
    where your fingers are currently present,
    instead of pressing arrow keys on a keyboard which is
    true on a desktop setup.
    
    Hence we place the best matching options
    not at the top of the typeahead menu, but
    instead put them at the bottom for better
    reachability and convenience of the user.
    
    Tests have been added to verify the
    emoji and mention render behavior.
    
    Also mentions dependencies on #226 where
    required.
    
    Co-authored-by: Zixuan James Li <[email protected]>
    Fixes #1121.

@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from 35f9a10 to 81729e8 Compare January 15, 2025 17:42
@apoorvapendse
Copy link
Contributor Author

Changelog @PIG208

  1. Rename emojiSequence to emojiNames here and icon to emojiName here and here as per suggestion1 and suggestion2
  2. Removed the redundant check as suggested.
  3. Removed the redundant comment as suggested.
  4. Removed because as per this.
  5. Updated the formatting here as pointed out here.
  6. Removed this from the commit message.
  7. Incorporate the change in Fix failing tests for RawAutocomplete #1190 for both the mention and emoji tests.

I think I've addressed all your suggestions and this PR is ready for another review.

@PIG208
Copy link
Member

PIG208 commented Jan 15, 2025

I am unable to understand how you see the resolved link #1131 (review).

Oh right. That link (#1121) was converted into the full link when I drafted that message.

Let's change

Co-authored-by: Zixuan James Li <[email protected]>
Fixes #1121.

to

Co-authored-by: Zixuan James Li <[email protected]>
Fixes: #1121

Copy link
Member

@PIG208 PIG208 left a comment

Choose a reason for hiding this comment

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

All my remaining comments are small. Marking this for Greg's review.

test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
test/widgets/autocomplete_test.dart Outdated Show resolved Hide resolved
@PIG208 PIG208 added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Jan 15, 2025
@PIG208 PIG208 assigned gnprice and unassigned PIG208 Jan 15, 2025
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from 81729e8 to a7e39fc Compare January 16, 2025 02:06
@apoorvapendse
Copy link
Contributor Author

apoorvapendse commented Jan 16, 2025

Thanks a lot @PIG208 for your patient reviewing.
I’m planning to compile all the formatting suggestions you’ve provided here into a document, so I can use it as a checklist for future reviews and save you the trouble next time.

I've fixed the trailing commas and changed the "biohazard" wording to "last" as advised in the recent round.
And the commit message as suggested

This commit reverses the list that was originally
presented to the user while showing the typeahead menu.

This makes sense since on mobile its easier to click
on options closer to the input box, i.e.
where your fingers are currently present,
instead of pressing arrow keys on a keyboard which is
true on a desktop setup.

Hence we place the best matching options
not at the top of the typeahead menu, but
instead put them at the bottom for better
reachability and convenience of the user.

Also mentions dependencies on zulip#226 where
required.

Co-authored-by: Zixuan James Li <[email protected]>
Fixes: zulip#1121
@apoorvapendse apoorvapendse force-pushed the put-best-matches-near-fingers branch from a7e39fc to ed3d473 Compare January 16, 2025 02:13
@gnprice
Copy link
Member

gnprice commented Jan 16, 2025

Thanks @apoorvapendse and @PIG208 for all your work on this!

There's still an open question here of whether we want to make this change in the UX. That was Alya's feedback on the thread (in #mobile at the time because #mobile-design didn't exist yet; I've just moved it there) last month:
https://chat.zulip.org/#narrow/channel/530-mobile-design/topic/Put.20best.20autocomplete.20matches.20at.20bottom.20of.20list.20.23F1121/near/1999854

Given that state, I think it won't make sense to invest more effort into the implementation before further design discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Put best autocomplete matches at bottom of list, not top
3 participants