Skip to content

Conversation

@Kanata844
Copy link
Contributor

No description provided.

let clientX = $state(0);
let clientY = $state(0);
let onclick_dropdown_reply = $state(() => {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScript の命名規則はほとんどの場合スネークケース variable_name ではなくキャメルケース variableName なので、そのような名前にしてね。

class="menu dropdown-content bg-base-100 absolute z-[1] w-40 rounded-md border p-2 shadow"
>
<li>
<button onclick={onclick_reply}>返信</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ドロップダウンのメニューをこちら側で再実装するのではなく、 MessageList の方で #snippet を使って作ってやると onclick_ボタン名 みたいなのをボタンごとに渡さなくてもよくなりそう

そうすると MessageDropdown が複数 HTML に出てくることになるので、 visibility: hidden ではなく {#if visible}...{/if} で表示を操作してやると、やりたいことができると思う

Copy link
Contributor

@aster-void aster-void Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<!-- MessageDropdown.svelte -->
<script lang="ts">
  import type { Snippet } from "svelte";

  const {
    x,
    y,
    visible,
    children,
  }: { children: Snippet; x: number; y: number; visible: boolean } = $props();
</script>

{#if visible}
  <div
    style={`top: ${y}px; left: ${x}px; visibility: ${visible ? "visible" : "hidden"}`}
    class="fixed"
  >
    {@render children()}
  </div>
{/if}
<!-- MessageList.svelte (抜粋) -->
<script lang="ts">
  // 適切なタイミングで変更するハンドラを入れる
  let dropdownVisibleOn = $state<Id<"messages"> | null>(null);
</script>

{#each messages as message (message._id)}
  <MessageDropdown visible={dropdownVisibleOn === message._id}>
    {@render dropdownContent()}
  </MessageDropdown>
  {#snippet dropdownContent()}
    <ul>...</ul>
  {/snippet}
{/each}

Copy link
Contributor

@aster-void aster-void left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

よさそう

@aster-void aster-void merged commit 4168987 into main Aug 14, 2025
3 checks passed
@aster-void aster-void deleted the feat/rightclickdropdown branch August 14, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants