Ionic 5 How to make popover width dynamic

CSS Custom properties for ion-popover like min-width and max-width do not work.

If a popover contains a list of menu items then its width should adapt the width of the lengthiest menu item but should not exceed the set max-width.

For example,

–min-width: 240px;
–max-width: 320px;

The above values should behave like:
If the lengthiest menu item width > max-width then limit the width to max-width.
If the lengthiest menu item width > min-width and < max-width then limit the width to menu width.

But this does not work in Ionic 5 Angular app (platform ios).
Setting --width: auto; does not work.

Any idea how to achieve this?