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

feat: use React.forwardRef in all components #4233

Merged
merged 49 commits into from
Feb 28, 2023
Merged

feat: use React.forwardRef in all components #4233

merged 49 commits into from
Feb 28, 2023

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Jul 23, 2021

This PR is a part of work for Semantic UI React v3 🎉

All components in this PR have been converted to be functional components (Dropdown is an exception, it uses a wrapper) and use React.forwardRef() to forward refs natively.

@github-actions
Copy link

github-actions bot commented Jul 23, 2021

size-limit report

Path Size
bundle-size/dist/Button.size.js 54.04 KB (-8.79% 🔽)
bundle-size/dist/Icon.size.js 27.35 KB (+7.85% 🔺)
bundle-size/dist/Image.size.js 49.6 KB (-8.74% 🔽)
bundle-size/dist/Modal.size.js 62.6 KB (-10.12% 🔽)
bundle-size/dist/Portal.size.js 37.17 KB (-9.29% 🔽)

@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2021

Codecov Report

Base: 99.75% // Head: 99.51% // Decreases project coverage by -0.23% ⚠️

Coverage data is based on head (88974b5) compared to base (80c4d82).
Patch coverage: 99.05% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4233      +/-   ##
==========================================
- Coverage   99.75%   99.51%   -0.24%     
==========================================
  Files         180      186       +6     
  Lines        3248     3511     +263     
==========================================
+ Hits         3240     3494     +254     
- Misses          8       17       +9     
Impacted Files Coverage Δ
src/lib/hooks/useClassNamesOnNode.js 100.00% <ø> (ø)
src/modules/Popup/lib/createReferenceProxy.js 57.14% <ø> (ø)
src/modules/Search/SearchCategoryLayout.js 100.00% <ø> (ø)
src/lib/hooks/useEventCallback.js 75.00% <75.00%> (ø)
src/modules/Dimmer/Dimmer.js 90.47% <88.23%> (-9.53%) ⬇️
src/lib/hooks/useAutoControlledValue.js 91.66% <91.66%> (ø)
src/modules/Sticky/Sticky.js 94.64% <94.54%> (-4.44%) ⬇️
src/modules/Modal/Modal.js 98.83% <98.52%> (-1.17%) ⬇️
src/modules/Popup/Popup.js 98.94% <98.80%> (+0.01%) ⬆️
src/addons/Confirm/Confirm.js 100.00% <100.00%> (ø)
... and 165 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@layershifter layershifter changed the title chore: remove .state() assertions in tests (#4232) chore: v3 Jul 23, 2021
@layershifter layershifter changed the title chore: v3 chore: Semantic UI React v3 Jul 23, 2021
@layershifter layershifter linked an issue Jul 27, 2021 that may be closed by this pull request
layershifter and others added 14 commits December 13, 2022 13:44
* chore(Ref): remove component

* fix tests
* chore(Search): use React.forwardRef()

* add test for ref forwarding

* fix tests, add comments
* chore: refactor tests for shorthands to use mount()

* add comment

* fix tests with unmount
* Convert form to function component

* Add ref forwarding to Form component

* Update test/specs/collections/Form/Form-test.js

Co-authored-by: Oleksandr Fediashov <[email protected]>

Co-authored-by: Oleksandr Fediashov <[email protected]>
* Add ref to FormButton

* Add ref to FormCheckbox

* Add forwardRef to FormGroup

* Remove accidental `only` calls
* Add ref to form field component

* Move ref to controlProps

* Add more forwardsRef tests

* Remove unnecessary describe wrapper

* update tests

Co-authored-by: Oleksandr Fediashov <[email protected]>
* chore(Select): use React.forwardRef()

* chore(FormSelect): use React.forwardRef()

* chore(FormDropdown): use React.forwardRef()

* fix tests, fix Dropdown component

Co-authored-by: Oleksandr Fediashov <[email protected]>
@sunech
Copy link

sunech commented Dec 13, 2022

Awesome guys, really nice work with the progress these last couple of days! 👏👏

@felixmosh
Copy link
Contributor

#4408

PR is merged, thanks 🎉 It was the last step before the release. I will ping @levithomason to trigger 3.0.0-beta.

Do you think that we can use it for the displayName task?

Yes, thanks for doing that. I created an issue (#4409) to clarify the plan and steps related to release. Feel free to create a PR once this gets merged 👍

What should be merged? :]

@PerryRylance
Copy link

Thank you folks, been waiting a while for this

@layershifter
Copy link
Member Author

What should be merged? :]

Yes, thanks for doing that. I created an issue (#4409) to clarify the plan and steps related to release. Feel free to create a PR once this PR gets merged 👍

Oops, missed a word.

@levithomason
Copy link
Member

Giving this a test and look over 👀 Fantastic effort everybody, thank you 😍

@levithomason
Copy link
Member

I have been testing components and looking over changes this morning. Looks good! I will release the beta now and we can follow up on any clean up items. Superb job as usual @layershifter, much appreciated.

@levithomason levithomason merged commit 95ec819 into master Feb 28, 2023
@levithomason levithomason deleted the next-v3 branch February 28, 2023 17:04
@layershifter
Copy link
Member Author

Thanks everyone 👍

3.0.0-beta.0 is out 🎉 Please try and report issues 🙏

@felixmosh
Copy link
Contributor

except React.ref, what are the changed?

@layershifter
Copy link
Member Author

@felixmosh I will publish migration notes and guidance in upcoming days, shortly:

@sunech
Copy link

sunech commented Mar 4, 2023

Been running 3.0.0-beta.0 for in my dev environment for some days now. Tested a lot of the pages and functionality with it.

No issues so far, apart from the expected refs that needed to be changed for form elements. Great work!

@layershifter
Copy link
Member Author

FYI Migration guide is available (https://react.semantic-ui.com/migration-guide/), changelog was also updated.

@@ -195,7 +251,7 @@ export default class Popup extends Component {
) : (
children
)}
{hideOnScroll && <EventStack on={this.hideOnScroll} name='scroll' target='window' />}
{hideOnScroll && <EventStack on={hideOnScroll} name='scroll' target='window' />}
Copy link
Contributor

Choose a reason for hiding this comment

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

@layershifter after refactoring the Popup to FC, there is a hideOnScroll callback and prop name clash. It causes the guard be always truthy and thus the prop does not work. The callback should be renamed.

I think that this PR should be reviewed again because there might be more occurrences of this same issue. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

@dominikdosoudil good catch, please trigger an issue and feel free to submit a PR 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Apparently there exists both issue and PR #4490 (at least for the popup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use forward refs in Components to access ref instances