Skip to content

fix(frontend): fix no data on second click#1379

Open
hbz114514 wants to merge 1 commit intoUNIkeEN:mainfrom
hbz114514:fix-issue-1285
Open

fix(frontend): fix no data on second click#1379
hbz114514 wants to merge 1 commit intoUNIkeEN:mainfrom
hbz114514:fix-issue-1285

Conversation

@hbz114514
Copy link
Contributor

@hbz114514 hbz114514 commented Feb 15, 2026

Checklist

  • Changes have been tested locally and work as expected.
  • All tests in workflows pass successfully.
  • Documentation has been updated if necessary.
  • Code formatting and commit messages align with the project's conventions.
  • Comments have been added for any complex logic or functionality if possible.

This PR is a ..

  • 🆕 New feature
  • 🐞 Bug fix
  • 🛠 Refactoring
  • ⚡️ Performance improvement
  • 🌐 Internationalization
  • 📄 Documentation improvement
  • 🎨 Code style optimization
  • ❓ Other (Please specify below)

Related Issues

fix #1285

Description

修改了从实例的模组页面修改modloader时,第二次点击显示“无数据”的问题

Additional Context

  • Add any other relevant information or screenshots here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where clicking to change the mod loader a second time would display "no data" or a white screen in the modal. The fix wraps the ChangeModLoaderModal component with conditional rendering based on isChangeModLoaderModalOpen, forcing the component to unmount and remount each time the modal is opened. This ensures that stale state from previous modal sessions is cleared.

Changes:

  • Conditional rendering added to ChangeModLoaderModal to force component remount on each open

Comment on lines +578 to +584
{isChangeModLoaderModalOpen && (
<ChangeModLoaderModal
isOpen={isChangeModLoaderModalOpen}
onClose={onChangeModLoaderModalClose}
defaultSelectedType={targetLoaderType}
/>
)}
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

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

While conditional rendering fixes the "no data" issue by forcing component remount, this is a workaround rather than addressing the root cause. The proper fix would be to update the useEffect in ChangeModLoaderModal (line 56-65 of src/components/modals/change-mod-loader-modal.tsx) to include modalProps.isOpen in its dependency array, similar to how AddPlayerModal handles state reset. This would reset the modal state when it opens without the overhead of unmounting/remounting the entire component.

Example from AddPlayerModal:

useEffect(() => {
  setPlayername("");
  setPassword("");
  // ... reset other state
}, [modalProps.isOpen]);

The current conditional rendering approach works but has trade-offs: it causes the component to be completely recreated on each open, which may have minor performance implications.

Suggested change
{isChangeModLoaderModalOpen && (
<ChangeModLoaderModal
isOpen={isChangeModLoaderModalOpen}
onClose={onChangeModLoaderModalClose}
defaultSelectedType={targetLoaderType}
/>
)}
<ChangeModLoaderModal
isOpen={isChangeModLoaderModalOpen}
onClose={onChangeModLoaderModalClose}
defaultSelectedType={targetLoaderType}
/>

Copilot uses AI. Check for mistakes.
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.

[Bug] 修改模组加载器 modal 神秘白屏

1 participant