-
-
Notifications
You must be signed in to change notification settings - Fork 1k
[Web] Fix handling of enabled
prop
#3726
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
base: next
Are you sure you want to change the base?
Changes from all commits
c00cd6d
24b57ac
ad10a30
27c6c2d
1f81818
5e976fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ export default abstract class GestureHandler implements IGestureHandler { | |
private _state: State = State.UNDETERMINED; | ||
|
||
private _shouldCancelWhenOutside = false; | ||
private _enabled = false; | ||
private _enabled: boolean | null = null; | ||
|
||
private viewRef: number | null = null; | ||
private propsRef: React.RefObject<PropsRef> | null = null; | ||
|
@@ -712,16 +712,28 @@ export default abstract class GestureHandler implements IGestureHandler { | |
// Handling config | ||
// | ||
|
||
// Helper function to correctly set enabled property | ||
private updateEnabled(enabled: boolean | undefined) { | ||
if (enabled === undefined) { | ||
if (this._enabled) { | ||
return; | ||
} | ||
|
||
this._enabled = true; | ||
this.delegate.onEnabledChange(); | ||
} else if (this._enabled !== enabled) { | ||
this._enabled = enabled; | ||
this.delegate.onEnabledChange(); | ||
} | ||
} | ||
|
||
public setGestureConfig(config: Config) { | ||
this.resetConfig(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, the issue is that we reset the config here, but if the gesture was disabled before, we don't reattach the event listeners. Shouldn't we also try to attach listeners when resetting the config? At first glance, it looks like it could simplify this a lot (especially if it were to be done in a setter). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But in that case if we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we reverse that and start with detached listeners which are then attached when config has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So instead of attaching listeners in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Also, I don't know whether we will have any other logic that depends on * If we go through |
||
this.updateGestureConfig(config); | ||
} | ||
|
||
public updateGestureConfig(config: Config): void { | ||
if (config.enabled !== undefined && this.enabled !== config.enabled) { | ||
this._enabled = config.enabled; | ||
this.delegate.onEnabledChange(); | ||
} | ||
this.updateEnabled(config.enabled); | ||
akwasniewski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (config.hitSlop !== undefined) { | ||
this.hitSlop = config.hitSlop; | ||
|
@@ -911,7 +923,7 @@ export default abstract class GestureHandler implements IGestureHandler { | |
} | ||
|
||
protected resetConfig(): void { | ||
this._enabled = true; | ||
this._enabled = null; | ||
this.manualActivation = false; | ||
this.shouldCancelWhenOutside = false; | ||
this.mouseButton = undefined; | ||
|
Uh oh!
There was an error while loading. Please reload this page.