Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upNormalize behaviour of space vs. return for activating elements #22782
Comments
|
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the If you intend to work on this issue, then add |
|
@highfive assign me |
|
Hey @nishanthkarthik! Thanks for your interest in working on this issue. It's now assigned to you! |
|
@jdm This is my first issue on servo. Let me give it a shot! |
|
@nishanthkarthik Have you made progress? |
|
I'm on the test cases. I expect to send a PR by this weekend |
|
@jdm I tried
When I manually press space, it navigates away. It does not, when it is done through |
|
Oh, right. That makes sense, because there is no code in htmlanchorelement.rs to recognize key events and act on them. That being said, I just tested Firefox and Chrome, and they don't actually invoke links on space, so we should not deviate from their behaviour. However, they do activate a |
|
I think the right choice may be to add custom handle_event implementations for elements like That will allow us to write automated tests that verify that property. |
|
@highfive: assign me |
|
Hey @stevenloppe! Thanks for your interest in working on this issue. It's now assigned to you! |
|
@stevenloppe Are you working on this? |
|
Unassigning due to lack of activity. |
|
@highfive: assign me |
|
Hey @Ersikan! Thanks for your interest in working on this issue. It's now assigned to you! |
|
Unassigning due to lack of activity. |
|
@highfive assign me |
|
Hey @garasubo! Thanks for your interest in working on this issue. It's now assigned to you! |
TODO: write tests for my change
TODO: write tests for my change
TODO: write tests for my change
TODO: write tests for my change
Refactor submission This is my first contribution, so please correct me if I'm wrong I refactored the code as described #22782. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #22782 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Refactor submission This is my first contribution, so please correct me if I'm wrong I refactored the code as described #22782. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #22782 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Refactor submission This is my first contribution, so please correct me if I'm wrong I refactored the code as described #22782. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #22782 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
I'm sorry, but I found that one of commits were not included in the previous PR. I resubmit another PR to add this commit #24546. Could you take a look? |
Address this PR comment: https://github.com/servo/servo/pull/24489/files#diff-30a18e04d7e0b66aafdf192e416cad44R1472 This commit was failed to add in PR servo#24489. Issue: servo#22782
Re-add missing commit in PR #24489 Fix #22782 I'm sorry, but I failed to add one of commits during the squash phase in #24489. Could you review and merge this? --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Right now,
Document::dispatch_key_eventtriggers different behaviour for elements if you activate them with spacebar or return. Spacebar performs a synthetic click activation, while Return triggers implicit form submission. This means that pressing Return with an anchor element active does not navigate to the link, and special cases the behaviour for text input elements and buttons. I propose the following:implicit_submissionmethod from theActivatabletraitimplicit_submissionimplementation forHTMLButtonElemententirelyimplicit_submissionimplementation forHTMLInputElementa regular methoddispatch_key_event; remove any reference to implicit submissionThis should allow implicit submissions of forms from text inputs to continue working, since there is code in HTMLInputElement::handle_event to recognize the Return key already. Activating buttons with the Return key should also work as expected, since they will receive a synthetic click event.
Code:
components/script/dom/activation.rs,components/script/dom/document.rs,components/script/dom/htmlinputelement.rs,components/script/htmlbuttonelement.rsSome tests that might be relevant:
./mach test-wpt tests/wpt/web-platform-tests/html/semantics/forms/the-input-element/./mach test-wpt tests/wpt/web-platform-tests/html/semantics/forms/attributes-common-to-form-controls/./mach test-wpt tests/wpt/web-platform-tests/html/semantics/forms/form-submission-0/