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

bug: IonPopover size "auto" does not match content #27877

Closed
3 tasks done
Facj opened this issue Jul 28, 2023 · 9 comments
Closed
3 tasks done

bug: IonPopover size "auto" does not match content #27877

Facj opened this issue Jul 28, 2023 · 9 comments
Labels

Comments

@Facj
Copy link

Facj commented Jul 28, 2023

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

According to the documentation, IonPopover width will match popover content if type "auto" is selected in size attribute.
However, it forces width to 250px, the default size described in popover-md-width and does not adapt to wider content.

Expected Behavior

IonPopover width should adapt to content width when attribute size = "auto".

Steps to Reproduce

I have created a minimal app with three different pages that can be accessed using buttons in Home page. All of them include IonPopover or IonSelect with popover interface. Popover width does not match wide content in any of them.

Page1 includes a popover that can be opened using a button.
Page 2 include a form with IonSelect fields with popover interface.
Page 3 is the same as Page 2 but the form in nested inside a more complex page content, that matchs closely my real app.

Code Reproduction URL

https://github.com/Facj/ionpopover-issue

Ionic Info

$ ionic info

Ionic:

Ionic CLI : 6.6.0 (C:\Users\fcastro.NORVENTO\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/react 7.2.1

Utility:

cordova-res : not installed
native-run : 1.7.2

System:

NodeJS : v16.15.1 (C:\Program Files\nodejs\node.exe)
npm : 9.4.2
OS : Windows 10

Additional Information

There are quite a few related questions in Ionic forum (1, 2, ) and Stackoverflow (1, 2, 3 ) trying to set IonPopover size. Users are looking for CSS-based solutions, which would not be necessary if IonPopover size "auto" would actually match content width.

@ionitron-bot ionitron-bot bot added the triage label Jul 28, 2023
@liamdebeasi liamdebeasi self-assigned this Jul 28, 2023
@liamdebeasi
Copy link
Contributor

Thanks for the report. Can you clarify how you are trying to set the size of the popover? By default ion-popover uses a width of 250px. However, you can set --width: auto on the ion-popover host to have the popover be sized relative to the size of the child content.

I tried setting the following CSS in your app, and the popover was sized based on the size of its content:

ion-popover {
  --width: auto;
}

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Jul 28, 2023
@liamdebeasi liamdebeasi removed their assignment Jul 28, 2023
@ionitron-bot ionitron-bot bot removed the triage label Jul 28, 2023
@Facj
Copy link
Author

Facj commented Jul 31, 2023

Thanks! It does work as you say.

I was doing nothing to enforce popover size based on content. Reading the documentation, I assumed auto width was the default and, therefore, I thought this was a bug.

The actual behavior does make sense but the documentation is not clear.

imagen

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Jul 31, 2023
@liamdebeasi
Copy link
Contributor

I agree that this is confusing. I opened a PR to clarify this: #27894

I am going to close this since this is not a bug in Ionic, but let me know if you have any questions.

@liamdebeasi liamdebeasi closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2023
github-merge-queue bot pushed a commit that referenced this issue Jul 31, 2023
Issue number: N/A

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

See: #27877

The current description does not accurately describe what `size="auto"`
does.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Description clarifies that the width of the popover is set based on
platform defaults.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
@Facj
Copy link
Author

Facj commented Aug 1, 2023

Thanks for your help!

Going over the popovers in my code, I have realized --width: auto is not correctly applied when the list of options is long and scroll is needed. I have updated my minimal example to include a long list of options in Page2.

@liamdebeasi
Copy link
Contributor

Seems to be working on my end:
image

Setting --width: auto causes the popover to have a width of ~265px. Without the --width: auto it reverts back to its platform default of 250px.

@Facj
Copy link
Author

Facj commented Aug 2, 2023

On my end, there is a scroll in the popover and it seems to avoid the --width: auto enforcement.

imagen

Is it possible that your screen is big enough to fit all the options so no scroll is needed? Could you test a smaller screen size?

@liamdebeasi
Copy link
Contributor

The truncation is likely happening because of the scrollbar. I don't know if width: auto takes into account the scrollbar width across platforms.

@Facj
Copy link
Author

Facj commented Aug 4, 2023

Yes, it looks like the scrolllbar is the cause of the truncation.

It seems like width: auto is not applied anymore when the scrollbar appears because width is back to 250px.

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 3, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants