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 no empty message if forceSelection is false or introduce a new attribute showEmptyMessage #11831

Closed
pizzi80 opened this issue Apr 29, 2024 · 7 comments · Fixed by #11834 or #11842
Assignees
Labels
new feature workaround A workaround has been provided
Milestone

Comments

@pizzi80
Copy link

pizzi80 commented Apr 29, 2024

Description

Solution 1:
do not show the emptyMessage if forceSelection="false"

Solution 2:
introduce a new attribute showEmptyMessage

Describe the solution you would like

If the selection of a suggested element is not mandatory,
and there are no result from the completeMethod,
usually I'm just writing a new value and
I'm not interested if the are no suggested values...

Additional context

No response

@melloware
Copy link
Member

@pizzi80 can you be a little more clear on your scenario? Maybe a reproducer showing the issue.
PrimeFaces Test

@pizzi80
Copy link
Author

pizzi80 commented Apr 29, 2024

if the user is not forced to select an item from the suggested list of values
the empty message only brings confusion, for example

If you type something in the first input in the autocomple showcase,
the emptyMessage it's not what an user expect ...

https://www.primefaces.org/showcase/ui/input/autoComplete.xhtml?jfwid=d1c1b

Schermata del 2024-04-29 17-18-27

@pizzi80
Copy link
Author

pizzi80 commented Apr 29, 2024

I've found that if you set
emptyMessage="#{null}" or emptyMessage=""

the emptyMessage is not displayed

@melloware melloware removed the ‼️ needs-triage Issue needs triaging label Apr 29, 2024
@melloware melloware added this to the 14.0.0 milestone Apr 29, 2024
@pizzi80
Copy link
Author

pizzi80 commented Apr 29, 2024

only as a reminder ... the emptyMessage attribute it's not documented at all

https://primefaces.github.io/primefaces/13_0_0/#/components/autocomplete?id=autocomplete

@melloware
Copy link
Member

Yep i was going to say that but in PF14 this will be different as we removed the EmptyMesage property as labels got moved to the client side from the server side. So in 14 this would be either

MonkeyPatch:

if (PrimeFaces.widget.AutoComplete) {
    PrimeFaces.widget.AutoComplete.prototype.configureLocale = function() {
        this.emptyMessage = '';
        this.resultsMessage = PrimeFaces.getLocaleLabel('searchMessage');
        if (this.dropdown) {
            this.dropdown.attr('aria-label', PrimeFaces.getLocaleLabel('choose'));
        }
    }
};

Or change your local to have an empty search label this.emptyMessage = PrimeFaces.getLocaleLabel('emptySearchMessage');

@melloware melloware added the workaround A workaround has been provided label Apr 29, 2024
@melloware
Copy link
Member

i think for 14.0 we need to add showEmptyMessage like PrimeReact has https://primereact.org/autocomplete/#api.AutoComplete.props.showEmptyMessage

@melloware melloware self-assigned this Apr 29, 2024
@pizzi80
Copy link
Author

pizzi80 commented Apr 29, 2024

probably it's better, in this way you'll cover all the situations ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature workaround A workaround has been provided
Projects
None yet
2 participants