[PR #27934] fix(knowledge-base): regenerate child chunks not working completely #31898

Closed
opened 2026-02-21 20:50:21 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/27934

State: closed
Merged: Yes


Fixes #27933

Summary

Problem

The "Regenerate Child Chunks" feature in parent-child chunking mode was completely non-functional. Users could not regenerate child chunks after editing parent segments, which is critical for maintaining knowledge base quality in RAG applications.

Two critical issues:

  1. Modal Z-index Conflict: The confirmation modal was rendered behind the edit drawer (drawer z-index: 9999 > modal z-index: 60/1100), making it invisible to users.

  2. Event Handling Conflict: The drawer's global click listener (in capture phase) intercepted clicks before the modal's buttons could respond. Since the modal renders via React Portal (outside drawer's DOM tree), clicking the "Regenerate" button caused:

    • Drawer to close (detecting click outside)
    • Modal to disappear
    • No API request sent

Solution

1. Fixed Modal Z-index

  • Set wrapperClassName='!z-[10000]' on RegenerationModal to ensure it displays above the drawer

2. Leveraged Drawer's Built-in modal Property
Instead of modifying the generic Drawer component, we use its existing modal prop to disable click-outside behavior:

  • Added onModalStateChange callback prop to SegmentDetail component
  • Parent component tracks modal state via isRegenerationModalOpen
  • Dynamically passes modal={isRegenerationModalOpen} to Drawer
  • When modal={true}, drawer's click handler is disabled, allowing modal interactions

3. Improved UX

  • Automatically closes both modal and drawer after successful regeneration

Screenshots

Before After
Image Image
Image Image

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 dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/27934 **State:** closed **Merged:** Yes --- Fixes #27933 ## 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. --> ### Problem The "Regenerate Child Chunks" feature in parent-child chunking mode was completely non-functional. Users could not regenerate child chunks after editing parent segments, which is critical for maintaining knowledge base quality in RAG applications. **Two critical issues**: 1. **Modal Z-index Conflict**: The confirmation modal was rendered behind the edit drawer (drawer z-index: 9999 > modal z-index: 60/1100), making it invisible to users. 2. **Event Handling Conflict**: The drawer's global click listener (in capture phase) intercepted clicks before the modal's buttons could respond. Since the modal renders via React Portal (outside drawer's DOM tree), clicking the "Regenerate" button caused: - Drawer to close (detecting click outside) - Modal to disappear - No API request sent ### Solution **1. Fixed Modal Z-index** - Set `wrapperClassName='!z-[10000]'` on RegenerationModal to ensure it displays above the drawer **2. Leveraged Drawer's Built-in `modal` Property** Instead of modifying the generic Drawer component, we use its existing `modal` prop to disable click-outside behavior: - Added `onModalStateChange` callback prop to SegmentDetail component - Parent component tracks modal state via `isRegenerationModalOpen` - Dynamically passes `modal={isRegenerationModalOpen}` to Drawer - When `modal={true}`, drawer's click handler is disabled, allowing modal interactions **3. Improved UX** - Automatically closes both modal and drawer after successful regeneration ## Screenshots | Before | After | |--------|-------| | ![Image](https://github.com/user-attachments/assets/78ddfa8f-1376-479b-92fa-9491edefbcc0) | ![Image](https://github.com/user-attachments/assets/67cd2d73-bb21-486f-8120-b81c1e9803a4) | | ![Image](https://github.com/user-attachments/assets/d25788f9-d178-49c3-af88-c011705deb22) | ![Image](https://github.com/user-attachments/assets/1075f9b5-c7b5-4cf3-8d91-70d463ffaff1) | ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:50:21 -05:00
yindo closed this issue 2026-02-21 20:50:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31898