dify icon indicating copy to clipboard operation
dify copied to clipboard

refactor: refactor the button component using `forwardRef`

Open TinsFox opened this issue 1 year ago • 3 comments

Description

refactor the button component using forwardRef

The previous button component was disguised as a div, which would lose the original capabilities of HTML, such as form submission. This will prevent users from submitting when JavaScript capabilities are turned off. But when we follow web standards, we can bring a better experience

This submission includes three contents:

  1. Use forwardRef to reconstruct the button component
  2. Change the original type attribute to variant. Type is the original attribute of button. We should not modify it.
  3. Removed memo. As a basic component, memo is not required Fixes # (issue)

Type of Change

Please delete options that are not relevant.

  • [x] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement

How Has This Been Tested?

All button components should behave the same as before

Suggested Checklist:

  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] My changes generate no new warnings
  • [x] I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

TinsFox avatar May 14 '24 12:05 TinsFox

After this submission merge, all events related to Form submission can be triggered using HTML instead of using JavaScript methods.

TinsFox avatar May 14 '24 12:05 TinsFox

@TinsFox Hello there is a conflict in this pr.

crazywoola avatar May 27 '24 12:05 crazywoola

@crazywoola All conflicts have been resolved.

TinsFox avatar May 28 '24 02:05 TinsFox

@TinsFox Compared to the feature main, following files should change the original type attribute to variant

app/components/tools/add-tool-modal/index.tsx app/components/tools/add-tool-modal/tools.tsx app/components/tools/provider/detail.tsx app/components/tools/workflow-tool/index.tsx app/components/tools/workflow-tool/confirm-modal/index.tsx app/components/workflow/nodes/parameter-extractor/components/extract-parameter/update.tsx app/(shareLayout)/webapp-signin/page.tsx

JzoNgKVO avatar May 31 '24 06:05 JzoNgKVO