Skip to content

Conversation

@gilbarbara
Copy link
Owner

@gilbarbara gilbarbara commented May 26, 2025

This pull request introduces several updates to improve the functionality, maintainability, and user experience of the project. Key changes include enhancements to the GitHub Actions workflow, updates to the README.md for better documentation, dependency upgrades, and new customization options for the Floater component. Below is a detailed breakdown of the most important changes:

Workflow and CI Updates

  • Updated .github/workflows/main.yml to use pnpm version 10 and Node.js version 22, enabling native caching of pnpm dependencies and simplifying setup.
  • Replaced the SonarCloud GitHub Action with the updated sonarqube-scan-action for improved compatibility.

Documentation Enhancements

  • Revamped README.md with clearer descriptions, improved formatting, and additional examples for customization and styling. Added detailed prop tables and updated usage examples to reflect new features like custom arrows and styles. [1] [2] [3] [4]

Component Customization

  • Added support for custom arrows in the Floater component via a new arrow prop, allowing users to provide their own SVG or ReactNode for the arrow. [1] [2]
  • Enhanced the Floater component's styling options by extending the styles prop to include additional customization capabilities.

Dependency Upgrades

  • Updated multiple dependencies across the project, including @emotion/react, @emotion/styled, typescript, and others, to their latest versions for improved performance and security. [1] [2]
  • Updated the demo dependencies in demo/package.json to align with the latest library versions and ensure compatibility.

Miscellaneous Improvements

  • Added a publicHoistPattern to pnpm-workspace.yaml to hoist ESLint-related dependencies, reducing duplication and improving workspace management.
  • Adjusted the Target example in the demo to include inline styles for better visual alignment.

These updates collectively enhance the developer experience, improve the library's flexibility, and ensure compatibility with modern tooling.

@gilbarbara gilbarbara requested a review from Copilot May 26, 2025 02:02
@codesandbox
Copy link

codesandbox bot commented May 26, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 26, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

This comment was marked as outdated.

@gilbarbara gilbarbara force-pushed the updates branch 2 times, most recently from 6f6de06 to f53b669 Compare May 26, 2025 12:15
Copy link

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 pull request introduces significant updates to improve the functionality, maintainability, and user experience of the react-floater library. The changes modernize the codebase with updated dependencies, enhanced testing patterns, and new customization features.

Key changes include:

  • Added custom arrow support via a new arrow prop for enhanced visual customization
  • Modernized React import patterns and hooks usage throughout the codebase
  • Updated testing approach with improved test utilities and consolidated snapshot testing
  • Enhanced documentation with better examples and comprehensive prop tables

Reviewed Changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/index.spec.tsx Refactored tests with modern React imports, improved test utilities, and added custom arrow testing
test/snapshots/*.snap Updated snapshots to reflect structural changes in component output
test/fixtures/components.tsx Modernized React imports and component organization
src/types/common.ts Added arrow prop type definition and reorganized type structure
src/modules/hooks.ts Removed unused useSingleton hook
src/modules/helpers.ts Removed unused React import and isValidElement helper
src/index.tsx Major refactor with modern React hooks, improved effect management, and arrow prop support
src/components/*.tsx Updated all components with modern React imports and arrow prop integration
pnpm-workspace.yaml Added ESLint dependency hoisting configuration
package.json Updated dependencies to latest versions
demo/src/examples/*.tsx Enhanced examples with custom arrow demonstrations
README.md Comprehensive documentation improvements with better structure and examples
.github/workflows/main.yml Updated CI workflow with pnpm v10 and Node.js v22
Comments suppressed due to low confidence (1)

test/index.spec.tsx:30

  • [nitpick] The variable name idWrapper could be more descriptive. Consider renaming to wrapperId or wrapperTestId to better indicate its purpose as a test identifier.
const idWrapper = `${id}-wrapper`;

view = setup({ ...localProps, event: 'hover' });

fireEvent.mouseEnter(getByDataId());
fireEvent.mouseEnter(screen.getAllByTestId(idWrapper)[0]);
Copy link

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

Using getAllByTestId(...)[0] suggests there might be multiple elements with the same test ID, which could lead to flaky tests. Consider using getByTestId instead or ensuring test IDs are unique.

Suggested change
fireEvent.mouseEnter(screen.getAllByTestId(idWrapper)[0]);
fireEvent.mouseEnter(screen.getByTestId(idWrapper));

Copilot uses AI. Check for mistakes.
}, []);

useSingleton(() => {
// Global load event listener (singleton)
Copy link

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

The global load event listener is added in every component instance but only removed in the cleanup of individual instances. This could lead to multiple listeners being attached if multiple ReactFloater components are mounted, but only the last one's cleanup will remove the listener.

Copilot uses AI. Check for mistakes.

if (arrow) {
return (
<span ref={arrowRef} style={{ color, height: length, width: spread }}>
Copy link

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

[nitpick] The custom arrow styling uses height: length, width: spread but this might not match the expected dimensions for all arrow orientations. Consider using consistent dimension naming or adjusting based on placement direction.

Suggested change
<span ref={arrowRef} style={{ color, height: length, width: spread }}>
<span
ref={arrowRef}
style={{
color,
height: placement.startsWith('left') || placement.startsWith('right') ? spread : length,
width: placement.startsWith('left') || placement.startsWith('right') ? length : spread,
}}
>

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 5, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
3 Security Hotspots

See analysis details on SonarQube Cloud

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.

2 participants