Conversation
|
Thanks for finding this bug and reporting it! (In the future @bryanhoffman it would be really helpful if you waited to be assigned to work on an issue before filing a PR. I know this can require a bit more patience, but it also helps reduce duplicate work or avoidable revisions. Thank you for understanding!) In this case, I'd like to reconsider the approach of adding a windowlistener. I would like to investigate a bit whether this might be a regression (I don't think so? @davepagurek does this seem like the behavior that's always been there?). If you have ideas on how to fix this in the component that displays the code and the sketch (not the sketch code itself), you are welcome to revise this. Also cc @doradocodes if you have any ideas related here! |
ksen0
left a comment
There was a problem hiding this comment.
Let's look for a solution that doesn't require changing sketch code itself, if at all possible!
…frame.tsx file instead of the examples themselves which was admittedly a sloppy solution.
|
@ksen0 I'm sorry! I thought what I was doing was helpful, but I'm very new to open source contributions. I don't know what happens on your end when I submit a PR. When I submit a PR, what "duplicate work or avoidable revisions" does it create? I appreciate the feedback, I want to be helpful and learn. Sorry for making a mess! As for fixing this without altering example code, if I run: in the console after changing it so it's running in the about:srcdoc context, it fixes the scrolling issue. I've attempted to place the logic in an appropriate place namely the src/components/CodeEmbed/frame.tsx file. |
|
@bryanhoffman no worries at all! n this case "duplicate work" doesn't apply , but we have the guideline against unassigned PRs (in contributor guidelines) because sometimes people make PRs to an issue someone else is already working on, which mean the unassigned PR has to be closed. When I say "avoidable revisions" I mean if code is written before there's an agreement on what actually the fix should be. In this example, what could have been done differently (what to do in the future): make the issue. Comment on the issue how you would fix it. A maintainer or steward (scroll down to the table here to see who that would be) would check and reply, assigning you the issue and providing feedback on the approach. The p5.js project is now over a decade old. The website is newer, but has many complex integrations. Even fixes that seem simple usually aren't and the process suggested in the guidelines is the way it is to try to build in ways to give technical guidance before contributors invest a lot of energy into a solution. I hope that clarifies! And welcome :) ! |
| } | ||
| ${code.css || ""} | ||
| </style> | ||
| <script> |
There was a problem hiding this comment.
It is very important not to make keyboard navigation unusable on the site as a whole: (WCAG 2.1)
cc website accessibility steward @coseeian - in this case, the sketch does something on keyboard arrow up/down. I assume the proposed solution, which ignores arrow up and down, would make keyboard navigation not usable. However, if it is possible to only ignore these when there is a sketch "in focus", would that be ok?
I am actually not sure how complex it would be to only do this when a sketch is "in focus" @bryanhoffman, if the current sketch viewer component has such information
There was a problem hiding this comment.
@ksen0 It should only ignore up and down arrows and the space bar when the sketch is "in focus." If I click the sketch it will start to ignore these keys, but if I then click outside of the sketch, the browser starts to "hear" up, down, and space again. I verified this locally. I think that should be suitable for accessibility concerns.
|
I’d like to raise a concern regarding the global application of this change. Intercepting these keys by default may inadvertently break examples that rely on native browser behavior. For instance, in the DOM Form Elements example, the Perhaps we should narrow the scope of this intervention to specific cases that require it (e.g., the Snake Game) while leaving the default iframe behavior untouched. |
|
@coseeian Here's my first PR where I put the logic into the example code itself: bryanhoffman@ffb29aefd Do you think this approach is preferrable? Alternatively, I'm starting to think that this might not be a website issue, but actually something needing ported to the p5.js library when keyIsPressed() or keyPressed() is used. I'm thinking the logic would go approximately here: https://github.com/processing/p5.js/blob/9206f8d542b248d767ecdc652a26de988926952c/src/events/keyboard.js#L443 I'm happy to hear thoughts on this. Thanks to everyone for the help! |
|
Sorry for back to back comments. I want to expound a little more on these couple of options. The more nuclear option is adding something like: to the p5.prototype._onkeydown function on line 443. One more alternative is the creation of a disableScrollKeys() function within the p5.js library. So, this would still rely on developers adding this function to their examples and would result in the example code changing but it seems to embody the friendly philosophy of the p5.js project. |
…p and down arrow keys are pressed
resolves #1277
Link: #1277