Skip to content

fix: space key handling for editable elements inside button #419

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

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

faraazb
Copy link
Contributor

@faraazb faraazb commented Apr 10, 2025

If there is a button element on the composed path, then the browser will send a click event on the button when space key is pressed in a nested element with contenteditable set to true. stopPropagation does not work as this is not a propagated event but a new event dispatched by the browser on the button element.
Due to this, the button itself or closest element with CSLP may get focussed.
So, whenever a button is found on the event's composed path, use custom space key handling.

@faraazb faraazb requested a review from a team as a code owner April 10, 2025 12:35
Copy link

github-actions bot commented Apr 10, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 69.92% 8142 / 11644
🔵 Statements 69.92% 8142 / 11644
🔵 Functions 68.03% 281 / 413
🔵 Branches 84.39% 979 / 1160
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/visualBuilder/utils/handleFieldMouseDown.ts 100% 92.3% 100% 100%
Generated in workflow #377 for commit 5dc41a2 by the Vitest Coverage Report Action

@faraazb faraazb requested a review from Copilot April 14, 2025 11:55
@faraazb faraazb changed the base branch from main to develop_v3 April 14, 2025 11:55
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/visualBuilder/utils/handleFieldMouseDown.ts:55

  • Consider verifying that 'event.composedPath' is supported before using it to avoid potential runtime errors in older or non-standard browsers.
if (event.composedPath().some(

src/visualBuilder/index.ts:65

  • [nitpick] The name 'focusFieldReceivedInput' might be unclear; consider renaming it to 'hasReceivedInput' for improved readability.
focusFieldReceivedInput: boolean;

@faraazb faraazb force-pushed the VE-5803-space-key-element-inside-button branch 2 times, most recently from e0055ea to c2070f7 Compare April 17, 2025 07:11
…ed path

If there is a button element on the composed path, then the browser will send a click
event on the button when space key is pressed. stopPropagation does not work as this
is not a propagated event but something done by the browser. So, whenever a button
is detected on the event's composed path, use custom space key handling.
@faraazb faraazb force-pushed the VE-5803-space-key-element-inside-button branch from c2070f7 to 5dc41a2 Compare April 17, 2025 07:13
Copy link
Contributor

@hiteshshetty-dev hiteshshetty-dev left a comment

Choose a reason for hiding this comment

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

LGTM!!

@faraazb faraazb merged commit 32a80bc into develop_v3 Apr 17, 2025
8 checks passed
@faraazb faraazb deleted the VE-5803-space-key-element-inside-button branch April 17, 2025 07:37
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.

2 participants