edwardsharp / sched-datepicker

yet another polymer datepicker
GNU General Public License v3.0
3 stars 4 forks source link

Remove selected class in Polymer starterkit not working #2

Closed Pablo-Aldana closed 6 years ago

Pablo-Aldana commented 7 years ago

Hello! Congrats for the component it looks great. I've found an issue while using the calendar in polymer starterkit. When you start to tap dates they are not un selected (even if the option multidate is false).

image

Reviewing the code I've seen the issue is related the shadow DOM created in the starterkit.

In the class sched-month-view.html -> function _dayTap. There is two lines to remove the selected days _toClear = this.querySelectorAll(':scope .selected');

This query selector is returning an empty array everytime. you can test it by printing the object in the console.

I've solved the issue by using the Polymer DOM function

_toClear = Polymer.dom(this.root).querySelectorAll('.selected');

This returns the current selected objects to be removed. And gets the issue solved :)

I do hope this can help you to improved your components or to others to solved the issue in their own code.

Regards

edwardsharp commented 7 years ago

hey there @Pablo-Aldana , thanks for the report. are you using the polymer 2.x starter-kit project?

is there any way you might be able to provide some example code that reproduces the issue you are having?

great that you found a work-around. one thing to watch out for is making sure that line only queries '.selected' in the scope of a single datepicker, does your fix work when there's multiple datepickers shown on the same page?

ZachMoreno commented 6 years ago

I've reproduced the issue, confirmed the solution put forward by @Pablo-Aldana , & submitted it as PR #4 . Thank you for this awesome component & for the fix!

edwardsharp commented 6 years ago

@ZachMoreno thanks for the feedback. can you share code that reproduces this issue?