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: Allow repeated texts #5675

Merged
merged 3 commits into from
Aug 7, 2024

Conversation

David-Moreira
Copy link
Contributor

This should make it so that when the field is left or committed our internal check does not reset the value because it does not find a matching value.

So basically now we have a GetItemValues and GetItemsByText so we can get multiple items / values out of a single text.

Testing Code:


<Row>
    <Column ColumnSize="ColumnSize.IsFull.OnMobile.IsHalf.OnTablet">
        <Card Margin="Margin.Is4.OnY">
            <CardHeader>
                <CardTitle>Autocomplete</CardTitle>
            </CardHeader>
            <CardBody>
                <Field Horizontal JustifyContent="JustifyContent.End">
                    <FieldLabel ColumnSize="ColumnSize.Is2">Select Value</FieldLabel>
                    <FieldBody ColumnSize="ColumnSize.Is10">
                        <Autocomplete TItem="Country"
                                      TValue="string"
                                      Data="@Countries"
                                      TextField="@(( item ) => item.Name)"
                                      ValueField="@((item) => item.Iso)"
                                      @bind-SelectedValue="selectedAutoCompleteSearchValue"
                                      @bind-SelectedText="selectedAutoCompleteText"
                                      Placeholder="Search..."
                                      Filter="AutocompleteFilter.StartsWith">
                            <NotFoundContent> Sorry... @context was not found! :( </NotFoundContent>
                            <ItemContent>
                                <Div Flex="Flex.InlineFlex.JustifyContent.Between" Width="Width.Is100">
                                    <Heading Margin="Margin.Is2.FromBottom">@context.Value</Heading>
                                    <Small>@context.Item.Capital</Small>
                                </Div>
                                <Paragraph Margin="Margin.Is2.FromBottom">@context.Text</Paragraph>
                            </ItemContent>
                        </Autocomplete>
                    </FieldBody>
                </Field>
                <Field Horizontal JustifyContent="JustifyContent.End">
                    <FieldBody ColumnSize="ColumnSize.Is10.Is2.WithOffset">
                        Selected value: @selectedAutoCompleteSearchValue
                    </FieldBody>
                    <FieldBody ColumnSize="ColumnSize.Is10.Is2.WithOffset">
                        Selected text value: @selectedAutoCompleteText
                    </FieldBody>
                </Field>
            </CardBody>
        </Card>
    </Column>
</Row>

@code{
    private List<Country> Countries { get; set; } = new List<Country>() { new( "Portugal1", "PT", "Lisbon" ), new( "Portugal", "PT", "Lisbon" ), new( "Portugal", "PT-BR", "Lisbon" ), new( "Portugal", "PT-PT", "Lisbon" ), new( "France", "fr", "Paris" ), new( "Poland", "pl", "Warsaw" ) };

    private string selectedAutoCompleteSearchValue { get; set; }
    private string selectedAutoCompleteText { get; set; }

}

@David-Moreira David-Moreira linked an issue Aug 5, 2024 that may be closed by this pull request
Copy link
Collaborator

@stsrki stsrki left a comment

Choose a reason for hiding this comment

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

Looking good. Just add the release notes. And if you think it is worth adding an example in the docs you also do that.

@David-Moreira
Copy link
Contributor Author

Looking good. Just add the release notes. And if you think it is worth adding an example in the docs you also do that.

I wouldn't bother adding an example. It's not like it's a feature and it's most likely expected to work like this by default.

@stsrki stsrki changed the title Autocomplete | Allow repeated texts Autocomplete: Allow repeated texts Aug 7, 2024
@stsrki stsrki mentioned this pull request Aug 7, 2024
@stsrki stsrki merged commit b25397b into master Aug 7, 2024
2 checks passed
@stsrki stsrki deleted the 5352-autocomplete--allow-repeated-texts branch August 7, 2024 08:36
@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete : Allow repeated texts
2 participants