Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactor the button component using forwardRef #4379

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TinsFox
Copy link
Contributor

@TinsFox TinsFox commented May 14, 2024

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.

  • 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:

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

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. ☕️ typescript Pull request that update TypeScript code. 💪 enhancement New feature or request labels May 14, 2024
@TinsFox
Copy link
Contributor Author

TinsFox commented May 14, 2024

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

@takatost takatost requested a review from nite-knite May 14, 2024 15:47
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. size:M This PR changes 30-99 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. size:XL This PR changes 500-999 lines, ignoring generated files. labels May 20, 2024
@crazywoola
Copy link
Member

@TinsFox Hello there is a conflict in this pr.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 28, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 28, 2024
@TinsFox
Copy link
Contributor Author

TinsFox commented May 28, 2024

@crazywoola All conflicts have been resolved.

},
},
defaultVariants: {
variant: 'primary',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
variant: 'primary',
variant: 'default',

default variant should be 'default'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ths!

@JzoNgKVO
Copy link
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files. ☕️ typescript Pull request that update TypeScript code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants