Now I have the correct fix.
Primefaces 6.0 now has a new field called autoWidth, which is set to true by default, and you can set it to false.
IF you do, as some of the answers above say, and set it to false, all you do is play roulette using the css application. By setting it to false, perforations will leave this for you to control the width. You can either set the width specified in selectOneMeny according to the clear style attributes, or some css class in your application.
But this is not what this problem is about, this problem is related to the fact that the default behavior, not indicating any width in the drop-down list, leads to the fact that our drop downs are usually too small for shortcuts there.
So we really want autoWidth to work proplerly.
FInally, I looked at the component and the rendering, and it is obvious that the automatic width mechanism does not work on the server side. The backend side only builds some JSON-like data that the javascript landmark constructor can use to properly configure the browser for widget behavior.
If you are reading the 6.0 source code, the error is listed in META-INF \ resources \ primefaces \ forms
Find the code that says the following:
PrimeFaces SelectOneMenu Widget
In this javascript search function for a piece of code that says:
_render: function() { if(this.cfg.autoWidth) {
In this section of code, your error is the following line:
this.jq.css('min-width', this.input.outerWidth());
Here I applied the following patch, which we hope should work in order to get a drop-down list so that it is as bold as the largest label:
_render: function() { if(this.cfg.autoWidth) { // BEGIN: PATCHING // ORIGINAL CODE: // this.jq.css('min-width', this.input.outerWidth()); // BUGFIX: // (a) compute the original min-with primefaces 6.0 would put on the root div var primefacesBugWidth = this.input.outerWidth(); // (b) compute the length of the hidden select element with all the labels inside of it var widthOfHiddenDivWithSelectLabels = this.jq.find('div select').width(); var widthOfTheDropDownTriangle = this.jq.find('.ui-selectonemenu-trigger.ui-state-default.ui-corner-right').width(); var widthOfLabelPlusTraingle = widthOfHiddenDivWithSelectLabels + widthOfTheDropDownTriangle; // (c) we will use whichever length is longer // in bug-fixed primefaces version the outerWidth should be computed correctly // but this seems not to be the case var maxWidthOfTwoPossibleOptions = primefacesBugWidth > widthOfLabelPlusTraingle ? primefacesBugWidth : widthOfLabelPlusTraingle; this.jq.css('min-width', maxWidthOfTwoPossibleOptions); // END: PATCHING } }
The idea of ββthe code above: (a) look at the hidden div with all the labels and get the width of this div (b) add to this length the width needed for the triangle of downward triangles (c) compare the resulting width with the one suggested using feathers, and which seems too small.
Note: To install the patch, you must copy all the "Increments" code for SelectOneWidget. Add it to your javascript file under your control. Make sure that you only compile your javascript file after loading the javascript file.
Usually perforated are processed in HEAD. Therefore, if you have jasvacript as the last ement in the body, you should be fine.
The patch works fine for me. This is code that I don't like to maintain.