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

Cannot type in any HTML text field (filtering in full-screen visualization or renaming project in dashboard) #6828

Closed
Akirathan opened this issue May 24, 2023 · 18 comments
Assignees
Labels
--bug Type: bug d-intermediate Difficulty: some prior knowledge required p-high Should be completed in the next sprint

Comments

@Akirathan
Copy link
Member

image

To reproduce:

  • Open any table in full-screen visualization.
  • Open a filter for any column
  • Try to type into the text field that has just popped-up.

It can be reproduced on bd70ed6

@jdunkerley
Copy link
Member

This is in the viz pop up as well as the full screen one.

@farmaazon farmaazon added p-high Should be completed in the next sprint g-ensogl d-intermediate Difficulty: some prior knowledge required and removed triage labels May 25, 2023
@farmaazon
Copy link
Contributor

Probably related to recent event handling (but not prevent-default).

@wdanilo
Copy link
Member

wdanilo commented May 26, 2023

@farmaazon I believe this is cause by prevent default, why do you think otherwise? CC @vitvakatu, as you'd probably know that best, as you've been changing prevent-default behavior recently.

@farmaazon
Copy link
Contributor

I believe this is cause by prevent default, why do you think otherwise?

Thinking twice, I think I was mistaken.

@farmaazon farmaazon added this to the Design Partners milestone May 29, 2023
@farmaazon farmaazon moved this from ❓New to 📤 Backlog in Issues Board May 29, 2023
@farmaazon farmaazon changed the title Cannot type in a text field in full-screen visualization Cannot type in any HTML text field (filtering in full-screen visualization or renaming project in dashboard) May 31, 2023
@farmaazon
Copy link
Contributor

farmaazon commented May 31, 2023

The same cause seems to prevent us from renaming project name in the new dashboard. Should be checked as part of this task as well (https://discord.com/channels/401396655599124480/1113051687838560347/1113428099288277033)

Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

@somebody1234
Copy link
Contributor

well... it breaks all dashboard inputs which is kinda bad:

  • renaming projects
  • changing password
  • search bar
  • forms for creating assets
  • likely also login, if you sign out

@wdanilo
Copy link
Member

wdanilo commented Jun 1, 2023

If it's related, then it's even higher priority right now, as it breaks a lot of things. @vitvakatu do I remember correctly you've been handling the prevent defaults code recently? If so, can you look at it, please? CC @sylwiabr

@somebody1234
Copy link
Contributor

i think the simplest fix would be to bind all event listeners on #root instead of window. not 100% sure that's foolproof though.

the relevant code is here (not that it's useful for this issue):

impl DomBindings {
/// Create new Keyboard and Frp bindings.
///
/// We're preventing default on keyboard events, because we don't want the browser to handle
/// them.
pub fn new(keyboard: &Keyboard) -> Self {
let key_down = Listener::new_key_down(f!([keyboard](event:&KeyboardEvent) {
event.prevent_default();
keyboard.source.down.emit(KeyWithCode::from(event));
}));
let key_up = Listener::new_key_up(f!([keyboard](event:&KeyboardEvent) {
event.prevent_default();
keyboard.source.up.emit(KeyWithCode::from(event));
}));
let blur = Listener::new_blur(f_!(keyboard.source.window_defocused.emit(())));
Self { key_down, key_up, blur }
}
}

it's also worth noting that this is almost certainly due to leaked objects, which #6911 may fix

@wdanilo
Copy link
Member

wdanilo commented Jun 2, 2023

Handling of mouse events is more complex. On the Rust side we are listening to some events on window and on some events just on the WebGL canvas element. For example, we are listening for mouse move globally, but for mouse clicks, we are listening only on the canvas element. This allows us to get events correctly, when for example there is a DOM element above the canvas (then we don't want to handle the clicks, but we want to be able to handle mouse up for dropping things).

However, I don't see how this issue might be connected to either the decision on what element we are listening for the events nor how it could be connected to memory leaks on scene drop.

@somebody1234
Copy link
Contributor

what element we are listening for the events: if we don't listen on window, the event shouldn't be fired for keypresses on the dashboard (because the dashboard is separate div from #root) - so it would never even get a chance to (incorrectly) preventDefault in the first place

how it could be connected to memory leaks: ideally wasm drop should free the keyboard event listeners on window, since the ide should not be running at that point

@somebody1234
Copy link
Contributor

somebody1234 commented Jun 2, 2023

oh, but of course that wouldn't be a solution for events inside the ide itself (e.g. visualizations)

@wdanilo
Copy link
Member

wdanilo commented Jun 2, 2023

Wait, but the dashboard listens for events somehow, right? This is not connected to how we listen for events in Rust?

Regarding drop, it should work even with memory leaks. Look, we designed it this way not to "steal" events from other elements. For example, if you open performance window on top of Enso Graph, you can click there, and the events are passed correctly there. The same should be true for keyboard events. Enso should not steal events from DOM elements above it, so even with memory leaks, this should work fine.

@somebody1234
Copy link
Contributor

yeah - but the issue is that dashboard UI elements don't process the events because they're being preventDefaulted by rust.

as for not stealing events, that makes sense

i guess the ideal fix would be to only prevent_default when needed. but that might be difficult since the event immediately goes into frp, so you'd need some way to get the value back from frp, and even then i think that would only work if frp is synchronous, otherwise of course prevent_default wouldn't work

an alternative solution might be to only listen to events on the canvas element on which the IDE is rendering, and check that event.current_target == event.target, if that's viable? but on second thought you'd still want to prevent_default shortcuts like ctrl+r, even if they're not handled by the visualization...

so this might be a lot more difficult than it initially seems

@somebody1234
Copy link
Contributor

oh yeah re: dashboard listens for events somehow

i think it doesn't really listen to most keyboard events, the inputs not working are browser default behavior which is being preventDefaulted - since for custom event listeners it would be stopPropagation (if anything) that would prevent those from firing

@wdanilo
Copy link
Member

wdanilo commented Jun 2, 2023

I believe the solution is simpler than it seems. Why we are using preventDefault in the first place? It's an ugly beast and we should not use it if we don't have to! We use it to block some browser shortcuts like ctrl+r, that's it! Right now, we are doing prevent default on every keystroke if Im correct. Instead, we can do it on just predefined set of shortcuts, and everything should work fine. @vitvakatu, please confirm if Im right.

@farmaazon
Copy link
Contributor

If it's related, then it's even higher priority right now, as it breaks a lot of things. @vitvakatu do I remember correctly you've been handling the prevent defaults code recently? If so, can you look at it, please? CC @sylwiabr

Please note @wdanilo that this task is already scheduled for this iteration. It's assigned to me, and I will do it right after finishing the current task (that means today). Let's not make a confusion in the current work.

@vitvakatu
Copy link
Contributor

Instead, we can do it on just predefined set of shortcuts, and everything should work fine. @vitvakatu, please confirm if Im right.

Seems to be correct. Right now we prevent default for all keyboard events (keyup and keydown), but we can do that only for certain shortcuts (like ctrl-r). Though there might be an issue with the tab key. Apparently it causes weird bugs in IDE if not blocked, but it does not make sense to disable it in dashboard.

@somebody1234's suggestion about attaching keyboard events listeners to #root instead of window sounds good to me, but it needs to be checked.

@farmaazon farmaazon moved this from 📤 Backlog to 🔧 Implementation in Issues Board Jun 2, 2023
@wdanilo
Copy link
Member

wdanilo commented Jun 5, 2023

If it's related, then it's even higher priority right now, as it breaks a lot of things. @vitvakatu do I remember correctly you've been handling the prevent defaults code recently? If so, can you look at it, please? CC @sylwiabr

Please note @wdanilo that this task is already scheduled for this iteration. It's assigned to me, and I will do it right after finishing the current task (that means today). Let's not make a confusion in the current work.

I'm extremely sorry for the confusion! Thanks Adam for pointing it out!

@farmaazon farmaazon moved this from 🔧 Implementation to 🌟 Q/A review in Issues Board Jun 9, 2023
@farmaazon farmaazon moved this from 🌟 Q/A review to 🟢 Accepted in Issues Board Jun 12, 2023
@farmaazon farmaazon moved this from 🟢 Accepted to 🗄️ Archived in Issues Board Jun 13, 2023
@github-project-automation github-project-automation bot moved this from 🗄️ Archived to 🟢 Accepted in Issues Board Aug 30, 2023
@jdunkerley jdunkerley moved this from 🟢 Accepted to 🗄️ Archived in Issues Board Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
--bug Type: bug d-intermediate Difficulty: some prior knowledge required p-high Should be completed in the next sprint
Projects
Archived in project
Development

No branches or pull requests

6 participants