-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat(select): Adding check boxes to the multi-select menu #7455
Conversation
@@ -75,3 +75,17 @@ md-select-menu.md-THEME_NAME-theme { | |||
} | |||
} | |||
} | |||
|
|||
md-select-menu[multiple] { | |||
md-option { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent, please indent with two spaces, instead of one tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes- the indent should be +2 spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh apologies, my vimrc did not recognize scss and defaulted to 4 spaces. Corrected.
The checkbox borders in the screenshot seem exceptionally dark (black?) to me. |
4379748
to
7e29a30
Compare
@ErinCoughlan @jelbourn @KarenParker @gmoothart Please Review. I have refactored the select menu checkbox CSS to match the md-checkbox css (wherever applicable). References issue #3244. |
703f1db
to
d23334d
Compare
Going to explore refactoring the checkbox css such that you can use the same classes directly. Question @jelbourn: Where would prefer I put this css that will be used in both the select, checkbox, and potentially other components? |
@DerekLouie there should be one single place where the styles for a checkbox lives, and then each other component should consume those styles. |
d23334d
to
e37301b
Compare
0638d8a
to
906a1db
Compare
LGTM |
1 similar comment
LGTM |
906a1db
to
b703dc6
Compare
} | ||
} | ||
|
||
@mixin checkbox-container( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment explaining what this mixin does
@DerekLouie - we definitely need unit test(s) with this PR. |
b703dc6
to
fc21858
Compare
Hello All, I have added unit tests. I ran into an issue where element.find('._md-container') returned an empty sqlite object, my wild shot in the dark is that the underscore in the class name messes something up? I ended up for looping and using some good old native JS to verify the md-checkbox markup is correctly added. Please Review. Best, Derek |
@DerekLouie angular.element's |
if (selectCtrl.isMultiple) { | ||
element.attr('md-checkbox-enabled', ''); | ||
if (!checkboxElement) { | ||
checkboxElement = angular.element('<div class="_md-container"><div class="_md-icon"></div></div>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't there yet; you're still performing the html -> dom operation for every single item, everywhere. The goal is to only do that operation once ever, and then clone the result for each item.
You want to do something like
var CHECKBOX_SELECTION_INDICATOR =
angular.element('<div class="_md-container"><div class="_md-icon"></div></div>');
right inside of OptionDirective
before the return
, and then clone that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the behaviour you are describing is, in fact, what is going on here.
Actually if I clone element inside of the OptionDirective
right before the return
statement a new clone will be made every time the md-option
directive is invoked (if you put a debugger
on line 760 and navigate to the select demo page, you will notice you hit that debugger
breakpoint several times).
I have declared the variable at the very top of the file so there should only be one reference present in the code (kept alive in the parent closure), and it is instantiated IFF we have a multi-select (as close to lazy loading as I could manage).
We never clone the element again (if you put a debugger
on line 782 and navigate to the select demo page, you will notice you hit that debugger
breakpoint only once).
I agree though that I should rename the variable because my intention was to create a constant.
I believe putting that constant at the top of the OptionDirective
initially un-initialized but keeping the if statement would make the code more efficient than it was previously, but then detecting if the clone has been created already in other OptionDirective
's on the page becomes more difficult..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just misread the code. I wouldn't worry too much about the lazy initializing here; the cost of creating the element once at start-up should be pretty small.
fc21858
to
3ce1635
Compare
Hello All, I have fixed all the aforementioned comments! Please Review. Best, Derek |
3ce1635
to
e40bff0
Compare
e40bff0
to
5718b52
Compare
LGTM |
Hi, |
Can I do it with anguler-material 1.0.0? I only want to make minimum changes to our project, and get the multiple select with check box... |
This feature is available in v1.1.0 or higher. See the Select Demo Pizza Toppings which uses the multiple attribute:
|
This works for our standard I've opened #11759 to track supporting checkboxes when using |
@ErinCoughlan @jelbourn @KarenParker @gmoothart
Please Review.
Adding check boxes to the multi-select menu.
References issue #3244.