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): add mat-select-header component #7835

Closed

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 16, 2017

Adds a mat-select-header component, which is a fixed header above the select's options. It allows for the user to project an input to be used for filtering long lists of options.

This is a continuation of #3211 that polishes everything up, sorts out the a11y issues, fixes some animation issues and gets everything working with our current setup.

Note: This component only handles the positioning, styling, some basic focus management and exposes the panel id for a11y. The functionality is up to the consumer to handle.

Fixes #2812. Fixes #5697.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 16, 2017
@crisbeto crisbeto force-pushed the 2812/select-header-strikes-back branch from 118b730 to 9a102e6 Compare October 16, 2017 20:40
@crisbeto crisbeto force-pushed the 2812/select-header-strikes-back branch from 9a102e6 to 1c41bfb Compare October 16, 2017 20:55
@benb7760
Copy link

@crisbeto I am still seeing an issue I mentioned on previous PR;

  1. On demo app, switch the select to multiple and chang currentDrink to string[]
  2. Open select
  3. Tick Coke, Coffee
  4. Type 'tea' into header
  5. Tick 'Tea'
  6. Remove header filter
  7. Observe that Coke, Coffee, are no longer selected

Happy to open this as a separate issue if it is not in scope for this PR

As a slight extension, the following is also true:

  1. Set to multiple again
  2. Tick Coke
  3. Close select, observe placeholder 'Coke'
  4. Open select and type 'aaaa'.
  5. Observe that the Placeholder is now blank (this resolves itself once the filter is cleared)

@szymexpawlowski
Copy link

@crisbeto can we expect it in 2.0.0-beta.13?

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

Also update select.md? In particular I want to mention that the a11y is in the users hand with whatever they put in there.

@@ -638,6 +644,10 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
if (this.panelOpen) {
this._scrollTop = 0;
this.onOpen.emit();

if (this.header) {
this.header._trapFocus();
Copy link
Member

Choose a reason for hiding this comment

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

Add explanation for what you're doing w/ the focus-trap here?

@@ -0,0 +1,3 @@
<span cdkTrapFocus>
Copy link
Member

Choose a reason for hiding this comment

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

Do we always want to focus trap here? What's your reasoning for adding it by default instead of letting the user add it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd imagine that we do, just because the primary use case is having a search field. Also it removes a little bit of boilerplate for the consumer.

@@ -948,7 +958,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
this.empty ? 0 : this._getOptionIndex(this._selectionModel.selected[0])!;

selectedOptionOffset += MatOption.countGroupLabelsBeforeOption(selectedOptionOffset,
this.options, this.optionGroups);
this.options, this.optionGroups) + (this.header ? 1 : 0);
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment?

Adds a `mat-select-header` component, which is a fixed header above the select's options. It allows for the user to project an input to be used for filtering long lists of options.

**Note:** This component only handles the positioning, styling, some basic focus management and exposes the panel id for a11y. The functionality is up to the consumer to handle.

Fixes angular#2812.
@crisbeto crisbeto force-pushed the 2812/select-header-strikes-back branch from 1c41bfb to 2c3d45a Compare November 12, 2017 10:07
@crisbeto
Copy link
Member Author

Rebased and addressed the feedback @jelbourn, can you take another look?

Copy link
Contributor

@jrood jrood left a comment

Choose a reason for hiding this comment

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

Revert fdescribe to describe so that pull request doesn't break Travis CI.

@@ -56,7 +64,7 @@ const LETTER_KEY_DEBOUNCE_INTERVAL = 200;
const platform = new Platform();


describe('MatSelect', () => {
fdescribe('MatSelect', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there's a ban on fdescribe in tslint.json

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way that I can make this change and resubmit? Or is it necessary to wait for @crisbeto to make the change?

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't addressed it yet because I'm waiting for some more feedback, @jrood.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok thanks.

@jrood
Copy link
Contributor

jrood commented Nov 30, 2017

@kara @amcdnl Thanks for the work you're doing on this project! Sorry to bother, but I'm trying to keep this pull request in motion, and I believe @crisbeto is waiting for more feedback. If you have a chance, please let him know if you have any.

@jrood
Copy link
Contributor

jrood commented Dec 6, 2017

@jelbourn does crisbeto's rebase, per your feedback, look good to you?

@Maximaximum
Copy link

This feature would be really handy, hoping for this to get into a release soon :)

@Marcidius
Copy link

This can be viewed as essential, in my opinion. Just yesterday I was assisting my team lead to try and make this happen in a custom component but we ran into some roadblocks. I sure hope this gets some further attention and gets assigned to a release sooner than later.

@jrood
Copy link
Contributor

jrood commented Jun 19, 2018

See also #11806 which addresses the a11y concerns via an overlay.

@ngbot
Copy link

ngbot bot commented Jun 29, 2018

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

2 similar comments
@ngbot
Copy link

ngbot bot commented Jul 11, 2018

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@ngbot
Copy link

ngbot bot commented Jul 11, 2018

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@fxck
Copy link
Contributor

fxck commented Jul 11, 2018

Even @ngbot is so desperate to have this merged in.

@agiratech-vigneshm
Copy link

When this will be merged, It's actually solving a very good problem.

@kwkelly
Copy link

kwkelly commented Aug 28, 2018

Will this work with the new native select in #12707 , kind of like a datalist? I'm hoping for more native controls to improve the experience on mobile devices (especially some older ones that I have to deal with).

@ruant
Copy link

ruant commented Oct 7, 2018

Will this make it before version 7 is out?...

@mhosman
Copy link

mhosman commented Oct 11, 2018

Any news about this???

@mattiaskagstrom
Copy link

have this been forgotten? looks like a merge conflict is all thats keeping i back?

ping @jrood @crisbeto @josephperrott

@fxck
Copy link
Contributor

fxck commented Oct 12, 2018

I think the person that was working on those accessibility things is not working in this team anymore.

@mhosman
Copy link

mhosman commented Oct 12, 2018

This is a must-have feature at least for any back-end

@artparks
Copy link

the underlying select API is being changed so this is presumably dead

@liesahead
Copy link

When this will become available?

@kelvinlouis
Copy link

I think it is dead :(

@fxck fxck mentioned this pull request Jan 29, 2019
@akvaliya
Copy link

Any updates? Really disappointed that this important feature is still not exist.

@mmalerba mmalerba added aaa and removed aaa labels Apr 25, 2019
@shreeramk
Copy link

Any update on this? Waiting desperately for this feature.

@Splaktar
Copy link
Member

@shreeramk yes, you can find the update in #5697 (comment).

@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label May 30, 2019
@jelbourn
Copy link
Member

Closing this since we're going to work this feature into a larger revamp of the select rather than adding it to the current MatSelect implementation. We hope to have the new version available before the end of 2019.

@jelbourn jelbourn closed this Jun 13, 2019
@angular angular locked as resolved and limited conversation to collaborators Jun 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: search/filter in select feat(select): Add select header to the md-select