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

Dropdown | Deprecate autoDisplayFirst property #14426

Closed
cetincakiroglu opened this issue Dec 25, 2023 · 6 comments
Closed

Dropdown | Deprecate autoDisplayFirst property #14426

cetincakiroglu opened this issue Dec 25, 2023 · 6 comments
Assignees
Labels
Core Team Issue or pull request has been *opened* by a member of Core Team Type: Breaking Change Issue contains a breaking change related to a specific component
Milestone

Comments

@cetincakiroglu
Copy link
Contributor

cetincakiroglu commented Dec 25, 2023

  • autoDisplayFirst property will be removed in the future because of the maintenance time cost and model value collisions.

  • Instead of the autoDisplayFirst, users can set the value by the model value as shown below.


// component.html
<p-dropdown [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" placeholder="Select a City"></p-dropdown>


// component.ts
    cities: City[];

    selectedCity: City | undefined;

    ngOnInit() {
        this.cities = [
            { name: 'New York', code: 'NY' },
            { name: 'Rome', code: 'RM' },
            { name: 'London', code: 'LDN' },
            { name: 'Istanbul', code: 'IST' },
            { name: 'Paris', code: 'PRS' }
        ];
        this.selectedCity = this.cities[0] // same output with the autoDisplayFirst property, therefore it's not needed.
    }

@cetincakiroglu cetincakiroglu added Type: Breaking Change Issue contains a breaking change related to a specific component Core Team Issue or pull request has been *opened* by a member of Core Team labels Dec 25, 2023
@cetincakiroglu cetincakiroglu added this to the 17.2.1 milestone Dec 25, 2023
@cetincakiroglu cetincakiroglu self-assigned this Dec 25, 2023
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 25, 2023
@cetincakiroglu cetincakiroglu removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 25, 2023
@alexnoise79
Copy link
Contributor

it's a pity cause scenario like this cannot be used anymore, and they were very useful

<p-dropdown [options]="cities" ngModel optionLabel="name" (ngModelChange)="doThis($event)></p-dropdown>

@PeterHewat
Copy link

Documentation needs updating: https://primeng.org/dropdown#api.dropdown.props.autoDisplayFirst

@ArturJarosz
Copy link

ArturJarosz commented Apr 21, 2024

Isn't ngModel deprecated as well here as well?

@AlbaSS18
Copy link

And if I don't want to select any value, what value should I set? Null or undefined?

@majkers
Copy link

majkers commented May 27, 2024

It's a really bad change. What if we want to force user to select an item (so we don't want to select firs item) and option list is taken from service? We have to either spread it (option list) with empty|null value and label or use empty string as placeholder now...

@digitalcraftco
Copy link
Contributor

What about async as options now? #14190 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Team Issue or pull request has been *opened* by a member of Core Team Type: Breaking Change Issue contains a breaking change related to a specific component
Projects
None yet
Development

No branches or pull requests

7 participants