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

Call event.stopPropagation() with keyDownEvents specified. #8077

Merged
merged 5 commits into from
Jul 8, 2021

Conversation

rectified95
Copy link
Contributor

@rectified95 rectified95 commented Jun 22, 2021

The key(Down|Up)Events props control whether the event handling should be left exclusively to the JS, or at least the native processing should stop at the native control emitting it. This is to match this behavior on the JS side, by hooking into the onKeyDown|Capture callback and using event.stopPropagation() on the keys specified in keyDownEvents.

The change is in View and so works for Pressable too. I've made sure that the existing hooks in Pressable, which special-case Space continue to work with this.

Closes #5822

Microsoft Reviewers: Open in CodeFlow

@rectified95 rectified95 requested a review from a team as a code owner June 22, 2021 02:07
Copy link
Collaborator

@NickGerleman NickGerleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cc @rozele

const _keyUp = (event: KeyEvent) => {
if (props.keyUpEvents && !event.isPropagationStopped) {
for (const el of props.keyUpEvents) {
if (event.nativeEvent.code == el.code && el.handledEventPhase == 3) {
Copy link
Contributor

@jonthysell jonthysell Jun 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a constant somewhere we can use (or define) so as to not require a magic number here (and elsewhere)?

@rectified95 rectified95 changed the title Stop propagation Call event.stopPropagation() with keyDownEvents specified. Jun 23, 2021
@rectified95 rectified95 merged commit bc60ec2 into microsoft:main Jul 8, 2021
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

Successfully merging this pull request may close these issues.

Implement event.stopPropagation() when keyboarding declarative properties are set
3 participants