You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The p-selectButton component does not correctly select the default option value when the component is initialized. This issue occurs even when the ngModel is set to a default value, and allowEmpty is set to false.
Additional Information:
No errors are shown in the console.
The p-selectButton component does not highlight the default option on page load.
Attempted to manually add the p-highlight class using Renderer2, but it requires clicking the button twice to update the highlight.
Actual Behavior
The default option is not highlighted when the component is loaded. Additionally, when clicking on another option (e.g., "Rent"), the default option ("Buy") requires multiple clicks to toggle the highlight correctly.
Expected behavior
The p-selectButton component should correctly select and highlight the default option value when the component is initialized. Specifically:
When the ngModel is set to a default value (e.g., 'two') and allowEmpty is set to false, the corresponding button (e.g., 'Two') should be highlighted immediately upon loading the component.
The p-highlight class should be applied to the div element of the button corresponding to the default ngModel value, indicating that it is selected.
Users should not need to interact with the component (e.g., clicking the button) to see the default selection highlighted.
Given the following configuration in the component:
Describe the bug
The p-selectButton component does not correctly select the default option value when the component is initialized. This issue occurs even when the ngModel is set to a default value, and allowEmpty is set to false.
Additional Information:
p-selectButton
component does not highlight the default option on page load.p-highlight
class usingRenderer2
, but it requires clicking the button twice to update the highlight.I attached a stackblitz showing the issue.
Environment
Angular 18.1.1 Standalone SSR + PrimeNG 17.18.5
Reproducer
https://stackblitz.com/edit/angular-ssr-primeng?file=src%2Fapp%2Fapp.component.ts
Angular version
18.1.1
PrimeNG version
17.18.5
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
20.15.0
Browser(s)
126.0.6478.127 (Official Build) (64-bit)
Steps to reproduce the behavior
Create a p-selectButton component with the following configuration:
Initialize the component with the following values:
Load the component in a browser.
Actual Behavior
The default option is not highlighted when the component is loaded. Additionally, when clicking on another option (e.g., "Rent"), the default option ("Buy") requires multiple clicks to toggle the highlight correctly.
Expected behavior
The p-selectButton component should correctly select and highlight the default option value when the component is initialized. Specifically:
Given the following configuration in the component:
And the following initialization in the TypeScript file:
When the component is loaded, the 'Two' button should be highlighted, indicating it is selected by default.
The text was updated successfully, but these errors were encountered: