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(combobox): odd cursor behavior #17752

Conversation

ariellalgilmore
Copy link
Member

Closes #17222

Odd cursor behavior in combobox when typing "abc" then moving cursor between "a" and "b" the text was appear as "a1bc23" instead of "a123bc".

Screen.Recording.2024-10-15.at.9.56.24.AM.mov

resources: https://github.com/downshift-js/downshift/blob/master/src/hooks/useCombobox/README.md?plain=1#L581-L611

Changelog

Changed

  • removed cursor positioning and added setInputValue(newValue) on the change:

Testing / Reviewing

Check combobox storybook

@ariellalgilmore ariellalgilmore marked this pull request as ready for review October 15, 2024 16:58
@ariellalgilmore ariellalgilmore requested a review from a team as a code owner October 15, 2024 16:58
Copy link

netlify bot commented Oct 15, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 1681e87
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/671103649fcfb60008711650
😎 Deploy Preview https://deploy-preview-17752--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 15, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1681e87
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/671103649919ca000880cb0a
😎 Deploy Preview https://deploy-preview-17752--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.55%. Comparing base (d5ae548) to head (1681e87).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17752      +/-   ##
==========================================
- Coverage   79.56%   79.55%   -0.01%     
==========================================
  Files         406      406              
  Lines       14019    14014       -5     
  Branches     4336     4334       -2     
==========================================
- Hits        11154    11149       -5     
  Misses       2700     2700              
  Partials      165      165              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@Gururajj77 Gururajj77 left a comment

Choose a reason for hiding this comment

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

This looks good, thanks for refining this @ariellalgilmore

Comment on lines -800 to -805
useEffect(() => {
if (inputRef.current) {
inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
}
}, [inputValue, cursorPosition]);

Copy link
Member

Choose a reason for hiding this comment

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

Any idea what this was used for originally? It's wild that this whole useEffect was in there that not only wasn't needed, but actively caused a bug!

Copy link
Member Author

Choose a reason for hiding this comment

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

the cursorPosition came from the recent Autocomplete with Typeahead PR, but the odd cursor behavior was happening before that. When trying to fix the bug though, these additions seemed to probably help a weird cursor position when adding the autocomplete, so I realized fixing the original cursor bug also meant we could get rid of these new additions

Copy link
Contributor

@riddhybansal riddhybansal left a comment

Choose a reason for hiding this comment

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

This LGTM !!

Copy link

netlify bot commented Oct 17, 2024

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 1681e87
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/671103649fcfb60008711652
😎 Deploy Preview https://deploy-preview-17752--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ariellalgilmore ariellalgilmore added this pull request to the merge queue Oct 17, 2024
Merged via the queue into carbon-design-system:main with commit a7d18f1 Oct 17, 2024
39 of 40 checks passed
@ariellalgilmore ariellalgilmore deleted the fix/combobox-cursor-behavior branch October 17, 2024 14:11
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.

[Bug]: Odd Cursor Behaviour While Using ComboBox Component
5 participants