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

feat(select): align selected option over trigger #2026

Merged
merged 1 commit into from
Dec 2, 2016

Conversation

kara
Copy link
Contributor

@kara kara commented Nov 29, 2016

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 29, 2016
@kara kara force-pushed the select-offset branch 2 times, most recently from 64c57c8 to 503a168 Compare December 1, 2016 01:44
import {ConnectedOverlayPositionChange} from '../core/overlay/position/connected-position';
import {ConnectedOverlayDirective} from '../core/overlay/overlay-directives';
import {ViewportRuler} from '../core/overlay/position/viewport-ruler';

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a high level comment here explaining that you need to know a handful of style values here in order to properly align the selected item on open.

private _calculateOverlayPosition(): void {
this._offsetX = this._isRtl() ? SELECT_PANEL_PADDING_X : -SELECT_PANEL_PADDING_X;

const panelHeight = this.options.length <= SELECT_MAX_OPTIONS_DISPLAYED
Copy link
Member

Choose a reason for hiding this comment

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

Math.min(this.options.length * SELECT_OPTION_HEIGHT,  SELECT_PANEL_MAX_HEIGHT)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, good point

* y-offset so the panel can open fully on-screen. If it still won't fit,
* sets the offset back to 0 to allow the fallback position to take over.
*/
private _checkOverlayWithinViewport(maxScroll: number): void {
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't the behavior
"default position" > "fallback position" ( * n) > slide to stay on-screen

With the last one being part of the connected position strategy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(discussed over IM)


/** Sets the transform origin point based on the selected option. */
private _getOriginBasedOnOption(): string {
return `50% ${Math.abs(this._offsetY) - 9 + SELECT_OPTION_HEIGHT / 2}px 0px`;
Copy link
Member

Choose a reason for hiding this comment

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

- 9?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, that shouldn't be hardcoded. It's the heightDiff number. I'll fix!

select = fixture.debugElement.query(By.css('md-select')).nativeElement;
});

function checkTriggerAlignedWithOption(index: number): void {
Copy link
Member

Choose a reason for hiding this comment

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

Add comment

  /**
   * Asserts that the given option is aligned with the trigger.
   * @param index The index of the option.
   */

@kara kara force-pushed the select-offset branch 2 times, most recently from 7ade5cd to ae9d26c Compare December 1, 2016 19:25
@kara
Copy link
Contributor Author

kara commented Dec 1, 2016

@jelbourn Comments addressed

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Dec 1, 2016
@jelbourn
Copy link
Member

jelbourn commented Dec 1, 2016

LGTM

@tinayuangao tinayuangao merged commit 49d0c98 into angular:master Dec 2, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants