fluent-svelte-extra 2.2.2 → 2.2.3

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.
@@ -28,6 +28,7 @@ let mousePosition = {
28
28
  x: 0,
29
29
  y: 0
30
30
  };
31
+ let justClosed = false;
31
32
  $: dispatch(open ? "open" : "close");
32
33
  $: if (menu && tabbable(menuElement).length > 0)
33
34
  tabbable(menuElement)[0].focus();
@@ -42,6 +43,8 @@ $: if (anchorElement) {
42
43
  menuPosition.y = 0;
43
44
  }
44
45
  async function handleContextMenu({ clientX, clientY }) {
46
+ if (justClosed)
47
+ return;
45
48
  open = true;
46
49
  mousePosition = {
47
50
  x: clientX,
@@ -58,6 +61,20 @@ function mountMenu(node) {
58
61
  destroy: () => node.remove()
59
62
  };
60
63
  }
64
+ function handleOuterMousedown() {
65
+ open = false;
66
+ justClosed = true;
67
+ const handleMouseUp = () => {
68
+ setTimeout(() => {
69
+ justClosed = false;
70
+ });
71
+ };
72
+ window.addEventListener("mouseup", handleMouseUp, { once: true, capture: true });
73
+ setTimeout(() => {
74
+ window.removeEventListener("mouseup", handleMouseUp, { capture: true });
75
+ justClosed = false;
76
+ }, 1000);
77
+ }
61
78
  if (closeOnSelect) {
62
79
  setContext("closeFlyout", () => {
63
80
  dispatch("select");
@@ -77,7 +94,6 @@ if (closeOnSelect) {
77
94
  on:click|preventDefault|stopPropagation={openBy.includes("leftClick")
78
95
  ? handleContextMenu
79
96
  : undefined}
80
- on:contextmenu={openBy.includes("rightClick") ? handleContextMenu : undefined}
81
97
  bind:this={wrapperElement}
82
98
  >
83
99
  <slot />
@@ -88,7 +104,7 @@ if (closeOnSelect) {
88
104
  use:externalMouseEvents={{ type: "mousedown" }}
89
105
  on:contextmenu|stopPropagation={e => e.preventDefault()}
90
106
  bind:this={anchorElement}
91
- on:outermousedown={() => (open = false)}
107
+ on:outermousedown={handleOuterMousedown}
92
108
  class="context-menu-anchor"
93
109
  style="top: {menuPosition.y}px; left: {menuPosition.x}px;"
94
110
  >
@@ -44,7 +44,7 @@ $: {
44
44
  if (value === buttonValue) {
45
45
  const htmlButton = button;
46
46
  const width = htmlButton.offsetWidth;
47
- const left = htmlButton.offsetLeft - 1;
47
+ const left = htmlButton.offsetLeft;
48
48
  highlight.set({
49
49
  width,
50
50
  left
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluent-svelte-extra",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "A faithful implementation of Microsoft's Fluent Design System in Svelte.",
5
5
  "homepage": "https://github.com/OpenAnime/fluent-svelte-extra",
6
6
  "license": "MIT",