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

[Breaking] Proposal to handle selectedValue on the client side #191

Open
maheshj01 opened this issue Nov 25, 2024 · 2 comments
Open

[Breaking] Proposal to handle selectedValue on the client side #191

maheshj01 opened this issue Nov 25, 2024 · 2 comments
Labels
P1 High Priority: This is a show stopper and must be addressed immediately Proposal A detailed proposal for change to Searchfield. severe: new feature Request for a new capability or a feature

Comments

@maheshj01
Copy link
Owner

This issue proposes a change in how the value is selected in the SearchField component. Several bugs have been reported, such as breakdowns in keyboard navigation and selection highlighting. These issues can be resolved by explicitly managing the selectedValue in the consumer code.

Currently, the package automatically sets the selectedValue in the input field, which causes inconsistencies, especially when dealing with keyboard navigation and item highlighting.

Before
The package sets the selectedValue automatically inside the component, which leads to issues when navigating or selecting suggestions

SearchField(
    hint: 'Basic SearchField',
    dynamicHeight: true,
    maxSuggestionBoxHeight: 300,
    initialValue: SearchFieldListItem<String>('ABC'),
    suggestions: dynamicHeightSuggestion
        .map(SearchFieldListItem<String>.new)
        .toList(),
    suggestionState: Suggestion.expand,
),

After

We suggest that the selectedValue be managed explicitly in the client code (consumer code) by using the onSuggestionTap callback. This approach simplifies the API and provides more accurate control over the internal state of the package.

var selectedValue = SearchFieldListItem<String>('ABC');

SearchField(
    hint: 'Basic SearchField',
    dynamicHeight: true,
    maxSuggestionBoxHeight: 300,
    onSuggestionTap: (SearchFieldListItem<String> item) {
        setState(() {
        selectedValue = item;
        });
    },
    selectedValue: selectedValue,
    suggestions: dynamicHeightSuggestion
        .map(SearchFieldListItem<String>.new)
        .toList(),
    suggestionState: Suggestion.expand,
),

This change will make it clearer and more predictable how the selected value is handled and displayed, and it will improve keyboard navigation and item highlighting.

@maheshj01 maheshj01 added Proposal A detailed proposal for change to Searchfield. severe: new feature Request for a new capability or a feature P1 High Priority: This is a show stopper and must be addressed immediately labels Nov 25, 2024
@sabari7320
Copy link

when we expect this feature @maheshj01 ?

@maheshj01
Copy link
Owner Author

Hopefully Soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 High Priority: This is a show stopper and must be addressed immediately Proposal A detailed proposal for change to Searchfield. severe: new feature Request for a new capability or a feature
Projects
None yet
Development

No branches or pull requests

2 participants