Skip to content

Conversation

jonasfj
Copy link
Member

@jonasfj jonasfj commented Aug 26, 2024

This could probably use a few tests and some more polishing of CSS (and maybe position offsets).

image

Might be worth doing some tests in follow up PRs.

}

.search-completer-option:hover {
background-color: #ccc;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note to self: we should have tests that prevent submitting CSS values like this, and forces us to use the color palette that is for both light and dark mode.

This is fine for now, I will update these is a follow-up PR (as I want to also update the naming of the CSS variables).

Copy link
Contributor

@sigurdm sigurdm left a comment

Choose a reason for hiding this comment

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

Nice.

I'd love the styling to be more "material" eg. like: https://material.angular.io/components/autocomplete/overview#autocomplete-filter


// If not triggered automatically and not forced by Ctrl+Space, then
// we're done.
if (!state.triggered && !state.forced) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps use a switch here. It is not clear what states are left...

Copy link
Member Author

Choose a reason for hiding this comment

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

It is possible that a class hierarchy would be nice like:

sealed class State {}
final class InactiveState extends State {}
sealed class ActiveState extends State {}
final class NoSuggestionsState extends ActiveState {}
sealed class CompletingState extends ActiveState {}
final class ActiveTriggeredState extends CompletingState {}
final class ActiveForcedState extends CompletingState {}

Or something like that.. But it's also a bit in-sane to be doing that 🤣

After all, all the state here is inside one file, and it's a private thing.
It's used when:

  • rendering HTML,
  • tracking state (responding to input, focus change, selection change, etc),
  • handling keyboard input.

That's it.


The only messy thing right now is that suggestions depends on forced -- that could be fixed.

/// Completion is not active, happens whens:
/// * The input element doesn't have focus, or,
/// * There is a non-empty selection.
final bool inactive;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be an enum? Can we be eg. inactive and forced at the same time?

Copy link
Member Author

Choose a reason for hiding this comment

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

In theory yes, I think so.

)));
});

if (!request.acceptsGzipEncoding()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just reject the request?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm 50/50 on that, maybe it's the better choice.

name: 'q',
placeholder: placeholder,
autocomplete: 'on',
autocomplete: 'off',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this not be conditional on the experiment?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, we don't want the browser to auto-complete, it just suggests what you've typed before.

@jonasfj
Copy link
Member Author

jonasfj commented Aug 26, 2024

I'd love the styling to be more "material" eg. like: https://material.angular.io/components/autocomplete/overview#autocomplete-filter

Yes and no,

I want the dropdown to follow the caret, not the input field. Like how auto-complete works in an IDE.

Copy link
Collaborator

@isoos isoos left a comment

Choose a reason for hiding this comment

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

I think at this point this is close to be merged, and we should aim to do follow-up changes on specific parts separately from this PR.

Copy link
Collaborator

@isoos isoos left a comment

Choose a reason for hiding this comment

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

let's merge this + iterate over it

@jonasfj jonasfj merged commit 07942df into dart-lang:master Sep 4, 2024
32 checks passed
@jonasfj jonasfj deleted the search-completion branch September 4, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants