Ignore repeated key events for bound shortcuts, adjust visualization min width (#9537)

Fixes #8538 #9515

All repeated keyboard events handled through `defineShortcuts` are now ignored. For example, holding ctrl+v no longer pastes nodes repeatedly.

Also adjusted visualization min-width to 200px, since it was a trivial change.

![image](https://github.com/enso-org/enso/assets/919491/7997898f-bcee-45f2-aacb-e10a49b159d6)
This commit is contained in:
Paweł Grabarz 2024-03-25 20:29:31 +01:00 committed by GitHub
parent 70f847f295
commit 1872bb66ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -15,10 +15,10 @@ const props = defineProps<{
belowToolbar?: boolean
}>()
/** The total width of:
/** The minimum width must be at least the total width of:
* - both of toolbars that are always visible (32px + 60px), and
* - the 4px flex gap between the toolbars. */
const MIN_WIDTH_PX = 96
const MIN_WIDTH_PX = 200
const config = useVisualizationConfig()
@ -194,7 +194,7 @@ const resizeBottomRight = usePointer((pos, _, type) => {
<style scoped>
.VisualizationContainer {
--node-height: 32px;
--permanent-toolbar-width: 96px;
--permanent-toolbar-width: 200px;
color: var(--color-text);
background: var(--color-visualization-bg);
position: absolute;

View File

@ -391,6 +391,9 @@ export function defineKeybinds<
>,
): (event: Event_, stopAndPrevent?: boolean) => boolean {
return (event, stopAndPrevent = true) => {
// Do not handle repeated keyboard events (held down key).
if (event instanceof KeyboardEvent && event.repeat) return false
const eventModifierFlags = modifierFlagsForEvent(event)
const keybinds =
event instanceof KeyboardEvent ?