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

fix: add default targetEl for callout #248

Merged
merged 12 commits into from
Jun 17, 2024

Conversation

felicia-haggqvist
Copy link
Contributor

@felicia-haggqvist felicia-haggqvist commented Jun 11, 2024

Fixes Jira WARP-527

  • Update to latest version of @warp-ds/core dependency
  • Create a default targetEl when callout is true and targetEl is undefined.
  • Add a comment for the reason of creating a default targetEl:
    "useAutoUpdatePosition hook is using @warp-ds/core, which uses Floating-ui's computePosition(). Floating-ui's computePosition() requires a defined targetEl to be able to compute the attentionEl's position and the attentionEl's arrow position. When props.callout is true, we only need computePosition() to calculate the callout's arrow position. So, we create a default targetEl for callout that we can pass to the useAutoUpdatePosition hook, in order to avoid Floating-ui from throwing an error."
  • Add class ml-8 to the callout stories.
  • Fix eslint warnings from test files.

Tested:

  • Tested in Chrome, Firefox and Safari
  • Also tested in Server-side rendered app

@felicia-haggqvist felicia-haggqvist requested a review from a team June 11, 2024 09:16
@felicia-haggqvist felicia-haggqvist self-assigned this Jun 11, 2024
Copy link
Contributor

github-actions bot commented Jun 11, 2024

PR Preview Action v1.4.7
Preview removed because the pull request was closed.
2024-06-17 07:44 UTC

@felicia-haggqvist felicia-haggqvist changed the title fix: add start end suffix callout fix: add start end suffix for callout Jun 11, 2024
@felicia-haggqvist felicia-haggqvist changed the title fix: add start end suffix for callout fix: add default targetEl for callout Jun 11, 2024
@@ -92,7 +93,7 @@ export function Attention(props: AttentionProps) {
attentionEl.current = v;
},
get targetEl() {
return targetEl?.current;
return targetElRef.current;
Copy link
Contributor

Choose a reason for hiding this comment

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

targetElRef can be null so maybe do targetElRef?.current just so the null is handled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good catch! 👍

@@ -126,6 +126,7 @@ describe('TextArea component', () => {
const textAreaRef = createRef<HTMLTextAreaElement>();

// Render the TextArea component and pass the ref as forwardRef
// eslint-disable-next-line no-unused-vars
const { container } = render(<TextArea ref={textAreaRef} />);
Copy link
Contributor

Choose a reason for hiding this comment

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

This could just be (without the eslint-disable):

// Render the TextArea component and pass the ref as forwardRef
render(<TextArea ref={textAreaRef} />);

@felicia-haggqvist felicia-haggqvist merged commit e297880 into next Jun 17, 2024
4 checks passed
@felicia-haggqvist felicia-haggqvist deleted the fix/add-start-end-suffix-callout branch June 17, 2024 07:43
github-actions bot pushed a commit that referenced this pull request Jun 17, 2024
# [1.6.0-next.4](v1.6.0-next.3...v1.6.0-next.4) (2024-06-17)

### Bug Fixes

* add default targetEl for callout ([#248](#248)) ([e297880](e297880))
github-actions bot pushed a commit that referenced this pull request Jul 3, 2024
# [1.6.0](v1.5.0...v1.6.0) (2024-07-03)

### Bug Fixes

* add default targetEl for callout ([#248](#248)) ([e297880](e297880))
* bump core to fix slider ([#250](#250)) ([5192147](5192147))
* **slider:** Prevent onChange/onChangeAfter called on mount ([#253](#253)) ([84ddd64](84ddd64))

### Features

* add warp ds eslint config ([#238](#238)) ([d83f799](d83f799))
* slider onChangeAfter prop ([#247](#247)) ([fa1af5c](fa1af5c))
* **toggle:** add ReactNode type to toggle labels ([#244](#244)) ([abeff99](abeff99))
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