langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
46.81k stars 6.62k forks source link

Variables cannot be inserted using the variable picker if users hold down the mouse button for more than 200 milliseconds #8895

Open kurokobo opened 2 hours ago

kurokobo commented 2 hours ago

Self Checks

Dify version

0.8.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Open any prompt editor
  2. Enter / or {, or click {x} button
  3. Move the mouse over any variable and hold down the mouse button for more than 200 ms

✔️ Expected Behavior

When the mouse button is released, the selected variable is inserted.

❌ Actual Behavior

The variable picker is closed after 200 ms and the variable is not inserted when the mouse button is released.

The capture contains three slow clicks that take more than 200 ms (which failed to insert variables) and three fast clicks (which succeeded in inserting variables).

click_wf click_quick

Additional information

This has also been reported on Discord (I helped with the reporting as well).

dosubot[bot] commented 2 hours ago

The issue with the variable picker closing after 200 milliseconds when the mouse button is held down is due to the onClick event handler in the VariablePickerMenuItem component. This handler calls the selectOptionAndCleanUp function, which closes the menu immediately upon clicking. Additionally, there is a debounce mechanism in the LexicalTypeaheadMenuPlugin component, which has a default debounce time of 200 ms for its triggerFn [1].

To address this issue, you might need to adjust the onClick handler or the debounce mechanism to ensure that the variable picker remains open long enough for the variable to be inserted when the mouse button is released.

To continue talking to Dosu, mention @dosu.