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
fix(material-experimental/mdc-slider): fix change events on slider in… #22286
fix(material-experimental/mdc-slider): fix change events on slider in… #22286
Conversation
…puts * create GlobalChangeListener to handle listening for change events that occur on the document * stop all of the slider inputs change events from reaching users * dispatch our own fake change events from #emitChangeEvent in the slider adapter * use the GlobalChangeListener for change events instead of adding our own event listener in #registerInputEventHandler * keep track of and unsubscribe from the GlobalChangeListener in #deregisterInputEventHandler
I'm still working on the unit tests for this atm |
src/material-experimental/mdc-slider/global-change-and-input-listener.ts
Outdated
Show resolved
Hide resolved
const subject = this._subjects.get(type)!; | ||
const handler = this._handlers.get(type)!; | ||
|
||
return subject.pipe(finalize(() => { |
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.
Returning a subscription means that we can't use operators on the same stream. You can check out src\cdk\scrolling\scroll-dispatcher.ts
for an example of how this can be done using a custom observable.
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 think for this case, returning a subscription is sufficient. I think if we reach a point where we need to start using operators on the stream it would make sense to extend the functionality this way, but for the current use case and for the foreseeable future, this should be fine
I finished trying out using the native inputs under the hood and concluded that while it is possible, the cons outweigh the pros. The main issue with using native inputs is that for range sliders is this: In the case where the two thumbs are on top of each other, there is no intuitive way to decide which slider thumb the user is interacting with. Because the MDC implementation is not using the native inputs, it can wait until the user begins dragging in a direction to decide which thumb should be focused/active. With native sliders, you must decide which thumb is focused before the user even triggers a mousedown. |
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.
LGTM
angular#22286) * fix(material-experimental/mdc-slider): fix change events on slider inputs * create GlobalChangeAndInputListener to handle listening for change events that occur on the document * stop all of the slider inputs change events from reaching users * dispatch our own fake change events from #emitChangeEvent in the slider adapter * use the GlobalChangeAndInputListener for change events instead of adding our own event listener in #registerInputEventHandler * keep track of and unsubscribe from the GlobalChangeAndInputListener in #deregisterInputEventHandler
angular#22286) * fix(material-experimental/mdc-slider): fix change events on slider inputs * create GlobalChangeAndInputListener to handle listening for change events that occur on the document * stop all of the slider inputs change events from reaching users * dispatch our own fake change events from #emitChangeEvent in the slider adapter * use the GlobalChangeAndInputListener for change events instead of adding our own event listener in #registerInputEventHandler * keep track of and unsubscribe from the GlobalChangeAndInputListener in #deregisterInputEventHandler
angular#22286) * fix(material-experimental/mdc-slider): fix change events on slider inputs * create GlobalChangeAndInputListener to handle listening for change events that occur on the document * stop all of the slider inputs change events from reaching users * dispatch our own fake change events from #emitChangeEvent in the slider adapter * use the GlobalChangeAndInputListener for change events instead of adding our own event listener in #registerInputEventHandler * keep track of and unsubscribe from the GlobalChangeAndInputListener in #deregisterInputEventHandler
angular#22286) * fix(material-experimental/mdc-slider): fix change events on slider inputs * create GlobalChangeAndInputListener to handle listening for change events that occur on the document * stop all of the slider inputs change events from reaching users * dispatch our own fake change events from #emitChangeEvent in the slider adapter * use the GlobalChangeAndInputListener for change events instead of adding our own event listener in #registerInputEventHandler * keep track of and unsubscribe from the GlobalChangeAndInputListener in #deregisterInputEventHandler
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…puts
in #registerInputEventHandler
#deregisterInputEventHandler