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

Add onSelect and onCenterChange to the publicAPI. #188

Open
Alex-Aralis opened this issue Jan 2, 2019 · 0 comments
Open

Add onSelect and onCenterChange to the publicAPI. #188

Alex-Aralis opened this issue Jan 2, 2019 · 0 comments

Comments

@Alex-Aralis
Copy link
Contributor

The select and centerChange actions are already passed through the publicAPI but it's impossible to implement complicated selection logic on top of the default actions.

For instance, if the addon wants to perform multiple selections in a power-calendar-multiple, this is currently not possible on top of the current actions.select.

Elaboration: Imagine the user passes in a power-calendar-multiple onSelect handler but uses an addon selections child component. Ideally, the user would expect the onSelect action form the parent to be used by the addon selector component. So far so good, the handler is wrapped in the publicAPI.actions.select method and passed to the addon component. However, some default logic is implemented in the select action. select takes in a single date object, then merges it with the currently selected set of dates to produce the updated set that is then passed to the onSelect handler supplied to the power-calendar-multiple component. This is a convenient action handler, but there is no way to add multiple items to the selected list that is passed to the onSelect method. Therefore, because the onSelect handler is not passed through the publicAPI, there is no way to perform a selection state update that looks like [1, 2, 3] -> [1, 2, 3, 4, 5].

This is only one example of how not passing the handler restricts addons. For example consider the case of implementing a new selection mode in the power-calendar-range component. It would not be possible without having direct access to the user provided handlers because the default range selection logic is in the select action.

By directly exposing the handlers passed by the user, more direct, less coupled logic can be used by client addons.

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

No branches or pull requests

1 participant