Repository: melt-ui/melt-ui
Pull request #593 (2023-10-05 10:45:22)

chore: Gitpodify melt-ui
Made melt-ui gitpod ready so contirbutors can easily set it up in one click and get it up and running super quick.
Helps to review changes made in PR with ease.



changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: 1dc4dea935a62a7f688c91f89fba2ba4b04937c5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/KapadiaNaitik/melt-ui/new/develop?filename=.changeset/quiet-baboons-press.md&value=---%0A%22%40melt-ui%2Fsvelte%22%3A%20patch%0A---%0A%0Achore%3A%20Gitpodify%20melt-ui%0A)


KapadiaNaitik: @TGlide I have added it to contributing.md. Please review it and let me know.

Patch:
diff --git a/.changeset/fair-yaks-travel.md b/.changeset/fair-yaks-travel.md
new file mode 100644
index 00000000..a4ffa9c4
--- /dev/null
+++ b/.changeset/fair-yaks-travel.md
@@ -0,0 +1,5 @@
+---
+"@melt-ui/svelte": patch
+---
+
+Tooltip: Fix bug with `group` parameter
diff --git a/.gitpod.yml b/.gitpod.yml
new file mode 100644
index 00000000..6a405f50
--- /dev/null
+++ b/.gitpod.yml
@@ -0,0 +1,11 @@
+# This configuration file was automatically generated by Gitpod.
+# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
+# and commit this file to your remote git repository to share the goodness with others.
+
+# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
+
+tasks:
+  - init: pnpm install
+    command: pnpm run dev
+
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a6d2f0a1..03dc8099 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -124,3 +124,8 @@ broken.
 
 Lastly, run `pnpm run lint` && `pnpm run check` to ensure that everything is in order before
 submitting the pull request.
+
+## Contribute from a browser IDE 
+Make changes and contribute to OctoBot in a single click with an **already setup and ready to code developer environment** using Gitpod !
+
+[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/?autostart=true#https://github.com/melt-ui/melt-ui/tree/develop)
diff --git a/src/lib/builders/tooltip/create.ts b/src/lib/builders/tooltip/create.ts
index 5c84c686..9fcaafe7 100644
--- a/src/lib/builders/tooltip/create.ts
+++ b/src/lib/builders/tooltip/create.ts
@@ -258,18 +258,24 @@ export function createTooltip(props?: CreateTooltipProps) {
 	let isMouseInTooltipArea = false;
 
 	effect(open, ($open) => {
-		if (!$open) return;
+		const currentGroup = get(group);
+		if (currentGroup === undefined || currentGroup === false) {
+			return;
+		}
 
-		const groupValue = get(group);
-		if (groupValue === undefined || groupValue === false) {
+		if (!$open) {
+			if (groupMap.get(currentGroup) === open) {
+				// Tooltip is no longer open
+				groupMap.delete(currentGroup);
+			}
 			return;
 		}
 
 		// Close the currently open tooltip in the same group
 		// and set this tooltip as the open one.
-		const currentOpen = groupMap.get(groupValue);
+		const currentOpen = groupMap.get(currentGroup);
 		currentOpen?.set(false);
-		groupMap.set(groupValue, open);
+		groupMap.set(currentGroup, open);
 	});
 
 	effect([open, openReason], ([$open, $openReason]) => {


Test patch:
diff --git a/src/tests/tooltip/Tooltip.spec.ts b/src/tests/tooltip/Tooltip.spec.ts
index 76ad53ea..c4b99025 100644
--- a/src/tests/tooltip/Tooltip.spec.ts
+++ b/src/tests/tooltip/Tooltip.spec.ts
@@ -197,3 +197,18 @@ describe('2 tooltips, group=undefined', () => {
 		expect(get(open2)).toBe(true);
 	});
 });
+
+describe('Single tooltip, group=true', () => {
+	test('Tooltip does not prevent itself from opening', () => {
+		const open = writable(true);
+		render(Tooltip, {
+			open,
+			group: true,
+		});
+
+		open.set(false);
+
+		open.set(true);
+		expect(get(open)).toBe(true);
+	});
+});