vzcode 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.html CHANGED
@@ -24,7 +24,7 @@
24
24
  href="https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css"
25
25
  rel="stylesheet"
26
26
  />
27
- <script type="module" crossorigin src="/assets/index-29gn4hve.js"></script>
27
+ <script type="module" crossorigin src="/assets/index-4jXg5R0X.js"></script>
28
28
  <link rel="stylesheet" crossorigin href="/assets/index-esdlTXtH.css">
29
29
  </head>
30
30
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -1,5 +1,5 @@
1
1
  import { Button, Modal } from '../bootstrap';
2
- import { useCallback } from 'react';
2
+ import { useCallback, useEffect } from 'react';
3
3
 
4
4
  // Confirmation modal for deleting a file or directory.
5
5
  // Inspired by https://react-bootstrap.netlify.app/docs/components/modal/#live-demo
@@ -11,44 +11,55 @@ export const DeleteConfirmationModal = ({
11
11
  isDirectory,
12
12
  name,
13
13
  }) => {
14
- const handleSubmit = useCallback(
15
- (event) => {
16
- event.preventDefault();
17
- onConfirm();
14
+ const handleEnterKey = useCallback(
15
+ (event: KeyboardEvent) => {
16
+ if (event.key === 'Enter') {
17
+ onConfirm();
18
+ }
18
19
  },
19
20
  [onConfirm],
20
21
  );
21
22
 
23
+ useEffect(() => {
24
+ if (show) {
25
+ window.addEventListener('keydown', handleEnterKey);
26
+ } else {
27
+ window.removeEventListener('keydown', handleEnterKey);
28
+ }
29
+
30
+ return () => {
31
+ window.removeEventListener('keydown', handleEnterKey);
32
+ };
33
+ }, [show, handleEnterKey]);
34
+
22
35
  return (
23
36
  <Modal show={show} onHide={onClose} centered>
24
- <form onSubmit={handleSubmit}>
25
- <Modal.Header closeButton onClick={onClose}>
26
- <Modal.Title>
27
- Delete {isDirectory ? 'Directory' : 'File'}
28
- </Modal.Title>
29
- </Modal.Header>
37
+ <Modal.Header closeButton onClick={onClose}>
38
+ <Modal.Title>
39
+ Delete {isDirectory ? 'Directory' : 'File'}
40
+ </Modal.Title>
41
+ </Modal.Header>
30
42
 
31
- <Modal.Body>
32
- <p>
33
- This will delete the{' '}
34
- {isDirectory ? 'directory' : 'file'}{' '}
35
- <strong>{name}</strong>.
36
- </p>
37
- </Modal.Body>
43
+ <Modal.Body>
44
+ <p>
45
+ This will delete the{' '}
46
+ {isDirectory ? 'directory' : 'file'}{' '}
47
+ <strong>{name}</strong>.
48
+ </p>
49
+ </Modal.Body>
38
50
 
39
- <Modal.Footer>
40
- <Button
41
- variant="secondary"
42
- type="button"
43
- onClick={onClose}
44
- >
45
- Cancel
46
- </Button>
47
- <Button variant="primary" type="submit">
48
- Delete
49
- </Button>
50
- </Modal.Footer>
51
- </form>
51
+ <Modal.Footer>
52
+ <Button
53
+ variant="secondary"
54
+ type="button"
55
+ onClick={onClose}
56
+ >
57
+ Cancel
58
+ </Button>
59
+ <Button variant="primary" onClick={onConfirm}>
60
+ Delete
61
+ </Button>
62
+ </Modal.Footer>
52
63
  </Modal>
53
64
  );
54
65
  };
@@ -100,8 +100,11 @@ export const Item = ({
100
100
 
101
101
  // Function to handle confirmation on modal
102
102
  const handleConfirmModal = useCallback(
103
- (event: React.MouseEvent) => {
104
- event.stopPropagation();
103
+ (event: React.MouseEvent | undefined) => {
104
+ // TODO clean this up.
105
+ // This was added to prevent parent listeners from firing
106
+ // when the modal is confirmed.
107
+ event?.stopPropagation();
105
108
  setShowModal(false);
106
109
  handleDeleteClick();
107
110
  },