dify - ✅(Solved) Fix when add api-key the modal auto closed [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langgenius/dify#35456Fetched 2026-04-22 08:04:05
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
1
Author
Timeline (top)
commented ×1cross-referenced ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #35457: fix: keep Add API Key modal outside popover lifecycle in authorized flow

Description (problem / solution / changelog)

[!IMPORTANT]

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> <!-- If this PR was created by an automated agent, add `From <Tool Name>` as the final line of the description. Example: `From Codex`. -->

fix https://github.com/langgenius/dify/issues/35456

Root Cause and Context

During the #35431 , Authorized was migrated from PortalToFollowElem to @langgenius/dify-ui/popover. That migration itself is correct, but it exposed a lifecycle issue in existing modal ownership.

In the authorized flow, the “Add API Key” button is rendered inside the Popover content (Authorized -> Authorize -> AddApiKeyButton). AddApiKeyButton previously owned its own isApiKeyModalOpen state and conditionally rendered ApiKeyModal in its own subtree.

When users clicked inside the modal input, the parent Popover treated that interaction as outside and closed. Once Popover closed, the Popover content subtree unmounted, including AddApiKeyButton, so its local modal state was lost and the modal closed immediately.

Why this happened

The issue is not in AuthForm or modal form logic. It is a UI state ownership problem: a modal with independent lifecycle was mounted under a transient Popover subtree.

Fix

We moved “Add API Key modal” ownership to Authorized (outside Popover content) and changed AddApiKeyButton to support an external open handler. Now, in authorized mode, clicking “Add API” triggers an outer state update, and the modal remains mounted independently of Popover open/close state.

Result

  • Clicking/focusing the API key input no longer closes the modal unexpectedly.
  • Existing edit modal behavior remains unchanged.
  • Related plugin-auth tests pass after the change.

Screenshots

BeforeAfter
......

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Changed files

  • web/app/components/plugins/plugin-auth/authorize/add-api-key-button.tsx (modified, +11/-2)
  • web/app/components/plugins/plugin-auth/authorize/index.tsx (modified, +4/-1)
  • web/app/components/plugins/plugin-auth/authorized/index.tsx (modified, +16/-0)
RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.13.3

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

https://github.com/user-attachments/assets/111d7de5-2765-4f7d-80e9-0256aa8c8c86

in the latest main branch, when add api-key from the plugin detail modal, the api-key modal will auto closed

✔️ Expected Behavior

it will not auto closed

❌ Actual Behavior

No response

extent analysis

TL;DR

The API-key modal auto-closing issue in the latest main branch may be resolved by investigating the plugin detail modal's JavaScript code that handles the API-key addition process.

Guidance

  • Review the JavaScript code responsible for handling the API-key addition in the plugin detail modal to identify any potential issues that could cause the modal to close automatically.
  • Check the browser's console logs for any error messages that may indicate why the modal is closing unexpectedly.
  • Verify that the API-key modal's closure is not intended behavior in the latest main branch by comparing it with previous versions or checking the project's documentation.
  • Test the API-key addition process in different browsers or environments to see if the issue is specific to a particular setup.

Example

No code example can be provided without more context or information about the specific JavaScript code responsible for handling the API-key addition process.

Notes

The provided information lacks specific details about the code or the exact steps taken to reproduce the issue, making it challenging to provide a more precise solution. Further investigation into the codebase and debugging are necessary to identify the root cause.

Recommendation

Apply workaround: Temporarily revert to a previous version of the code or modify the JavaScript code handling the API-key addition to prevent the modal from closing automatically, until the root cause is identified and fixed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING