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

fix(material/autocomplete): autocomplete panel top is cut off in landscape mode #28982

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

essjay05
Copy link
Contributor

Fixes a bug in the Angular Material Autocomplete component where the autocomplete panel listbox top is cut off by the device screen when being viewed in landscape mode. This is because the listbox max-height is greater than the distance between the top of the autocomplete input and the screen top.

Fixes b/284148377

@essjay05
Copy link
Contributor Author

Googlers see internal.

Screenshot for bug fix test reference here.

// Prevents autocomplete panel from being cut-off from being viewed in landscape orientation.
@media all and (orientation: landscape) {
div.mat-mdc-autocomplete-panel {
max-height: 55vh;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we can count on 55vh since the position of the trigger and number of options can vary. The CDK overlay can be set up in a way that starts scrolling once it hits the viewport edge. We should be able to add something like this:

      .withFlexibleDimensions(true)
      .withGrowAfterOpen(true)
      .withViewportMargin(8)

Here: https://github.com/angular/components/blob/main/src/material/autocomplete/autocomplete-trigger.ts#L882

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @crisbeto! Will look into applying your recommended solution.

@essjay05 essjay05 force-pushed the autocomplete-landscape-listbox-a11y-fix branch from a20c534 to fe21a54 Compare May 1, 2024 22:57
@essjay05
Copy link
Contributor Author

essjay05 commented May 1, 2024

Screencast after recommended changes here

@essjay05 essjay05 force-pushed the autocomplete-landscape-listbox-a11y-fix branch from fe21a54 to 05b7c72 Compare May 2, 2024 16:02
@essjay05 essjay05 marked this pull request as ready for review May 2, 2024 16:22
@essjay05 essjay05 force-pushed the autocomplete-landscape-listbox-a11y-fix branch 2 times, most recently from 1acff7d to e7bb070 Compare May 9, 2024 20:03
@essjay05 essjay05 force-pushed the autocomplete-landscape-listbox-a11y-fix branch 3 times, most recently from 7567ce5 to f58576f Compare May 16, 2024 15:52
const strategy = this._overlay
.position()
.flexibleConnectedTo(this._getConnectedElement())
.withFlexibleDimensions(false)
.withPush(false);

// Check breakpoint if being viewed in HandsetLandscape
const isHandsetLandscape = this._breakpointObserver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a subscription object not a boolean? Also I think we need to unsubscribe / takeUntil(destroyed)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmalerba Thanks for the note! I've made the change to unsubscribe in my latest commit. Let me know if it's good to go and I'll make the request to merge.

@essjay05 essjay05 force-pushed the autocomplete-landscape-listbox-a11y-fix branch from f61af54 to 30ae78e Compare May 20, 2024 20:31
…scape mode

Fixes a bug in the Angular Material Autocomplete component where the
autocomplete panel listbox top is cut off by the device screen when being
viewed in landscape mode. This is because the listbox max-height is greater
than the distance between the top of the autocomplete input and the screen top.

Fixes b/284148377
…scape mode

Fixes lint error from previous commit which fixes Angular Component's
autocomplete panel top from being cut off when viewed in landscape mode.
The previous max-height of the panel is more than the height of the panel
from the top of the input when in the bottom half to the top of the device's
screen.

Fixes b/284148377
…pe mode

Fixes a bug in the Angular Material Autocomplete component where the
autocomplete panel listbox is cut off by the device screen when being
viewed in landscape mode. This is because the CDK overlay does not
adjust its size based on the screen constraints when triggered.

Fixes b/284148377
…landscape mode

Fixes a bug in the Angular Material Autocomplete component where the
autocomplete panel top was being cut off by the screen in mobile
landscape mode. Updates previous fix to target adjustments on
HandsetLandscape only.

Fixes b/284148377
…bile landscape mode

Removing unnecessary comments.

Fixes: b/284148377
…ests

Fixes broken presubmit tests for Angular Component's Autocomplete
constructor by injecting BreakpointObserver rather than adding to the
constructor.

Fixes b/247881646
Fixes breaking Angular Component Autocomplete comoponent's autocomplete
spec.ts so that the value falls within an acceptable range based on the
new behavior of the autocomplete in landscape mode.

Fixes b/284148377
…e view

Updates previous fix to unsubscribe from the _breakpointObserver on
ngOnDestroy.

Fixes b/284148377
@essjay05 essjay05 force-pushed the autocomplete-landscape-listbox-a11y-fix branch from 30ae78e to 1c44579 Compare May 22, 2024 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants