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

#10289: Cursor position is shifted incorrectly in Localized number field component #10312

Merged
merged 10 commits into from
May 20, 2024

Conversation

mahmoudadel54
Copy link
Collaborator

Description

In this PR, fixing cursor position shifting incorrectly in Localized number field component

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

#10289

What is the current behavior?
#10289

What is the new behavior?
For Localized number field component, if user edits/adds/deletes numbers into the input, the cursor will move in a correct way.

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

…lized number field component

Description:
- fix the jumping cursor to unexpected positions for localized numeric input
…lized number field component

Description:
- replace logic in updateDidMount to onKeyUp
- remove unused comments
…lized number field component

Description:
- remove unused method in IntlNumberFormControl
Description:
- resolve FE failure in unit test
@mahmoudadel54 mahmoudadel54 linked an issue May 14, 2024 that may be closed by this pull request
1 task
Copy link
Contributor

@dsuren1 dsuren1 left a comment

Choose a reason for hiding this comment

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

@mahmoudadel54
In most cases, the cursor position behaves correctly, except for few these. Kindly check. Thanks!

  • With fractional/decimal digit, on focus field value becomes unformatted

    fractional_unformatted.mp4
  • Follow up to above issue, the cursor position is incorrect when deleting fractional digits probably caused by unformatted value

    unformatted_cursor_position_incorrect.mp4

web/client/components/I18N/IntlNumberFormControl.jsx Outdated Show resolved Hide resolved
web/client/components/I18N/IntlNumberFormControl.jsx Outdated Show resolved Hide resolved
web/client/components/I18N/IntlNumberFormControl.jsx Outdated Show resolved Hide resolved
@mahmoudadel54
Copy link
Collaborator Author

mahmoudadel54 commented May 15, 2024

@mahmoudadel54 In most cases, the cursor position behaves correctly, except for few these. Kindly check. Thanks!

  • With fractional/decimal digit, on focus field value becomes unformatted

    fractional_unformatted.mp4
    
  • Follow up to above issue, the cursor position is incorrect when deleting fractional digits probably caused by unformatted value

    unformatted_cursor_position_incorrect.mp4
    

These are because this regex which located in NumericInput:

const RE_INCOMPLETE_NUMBER = /^([+-]|[+-]?\d+\.\d+0*|[+-]\.0*|[+-]?\d+\.)?$/;

it sees number like: 321.235 as incomplete number

@dsuren1 I need more clarifications about the cases this regular expression should handle.

…lized number field component [resolve review comments]

Description:
- fix issue of on focus effect in NumericInput
…lized number field component [resolve review comments]

Description:
- fix FE issue in onKeyDown in IntlNumberFormControl
…lized number field component [resolve review comments]

Description:
- revert unnecessary change
Copy link
Contributor

@dsuren1 dsuren1 left a comment

Choose a reason for hiding this comment

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

@mahmoudadel54

  • Add unit tests for these cases

  • Cursor position shift incorrectly as we type. I didn't see this before previous commit. Kindly check it. Thanks!

    incorrect_cursor.mp4

@mahmoudadel54
Copy link
Collaborator Author

@mahmoudadel54

  • Add unit tests for these cases

  • Cursor position shift incorrectly as we type. I didn't see this before previous commit. Kindly check it. Thanks!

    incorrect_cursor.mp4
    

Hi @dsuren1
can you please double check again? as I made double check and it works well

cursor.issue.working.as.expected.mp4

@dsuren1
Copy link
Contributor

dsuren1 commented May 16, 2024

Hi @dsuren1 can you please double check again? as I made double check and it works well

Like I mentioned over chat, it happens when user types the value a little fast. Kindly give it a try like we discussed. Thanks!

…lized number field component [resolve review comments]

Description:
- move the fixing logic of cursor position to componentDidUpdate instead of onKeyUp
Copy link
Contributor

@dsuren1 dsuren1 left a comment

Choose a reason for hiding this comment

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

@mahmoudadel54
Before reviewing this new change, I would also like this component to support onKeyUp function from consuming component in tandem with the changes incorporated for handing cursor

…lized number field component [resolve review comments]

Description:
- add onKeyUp as a prop into IntlNumberFormControl for any expected future consuming from a parent comp
@mahmoudadel54
Copy link
Collaborator Author

@mahmoudadel54 Before reviewing this new change, I would also like this component to support onKeyUp function from consuming component in tandem with the changes incorporated for handing cursor

Done

Copy link
Contributor

@dsuren1 dsuren1 left a comment

Choose a reason for hiding this comment

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

@mahmoudadel54
Rest looks good. Just minor amendments. And still unit tests are missing

web/client/components/I18N/IntlNumberFormControl.jsx Outdated Show resolved Hide resolved
web/client/components/I18N/IntlNumberFormControl.jsx Outdated Show resolved Hide resolved
web/client/components/I18N/IntlNumberFormControl.jsx Outdated Show resolved Hide resolved
…lized number field component [resolve review comments]

Description:
- add unit test
- resolve review comments
@dsuren1 dsuren1 merged commit ddf127e into geosolutions-it:master May 20, 2024
6 checks passed
@dsuren1 dsuren1 added the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label May 20, 2024
@dsuren1
Copy link
Contributor

dsuren1 commented May 20, 2024

@ElenaGallo Kindly test it in DEV and let us know if it's good to be backported. Thanks!

@ElenaGallo
Copy link
Contributor

Test passed, @mahmoudadel54 please backport to 2024.01.xx. Thanks

mahmoudadel54 added a commit to mahmoudadel54/MapStore2 that referenced this pull request May 21, 2024
…lized number field component (geosolutions-it#10312)

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component
Description:
- fix the jumping cursor to unexpected positions for localized numeric input

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component
Description:
- replace logic in updateDidMount to onKeyUp
- remove unused comments

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component
Description:
- remove unused method in IntlNumberFormControl

* geosolutions-it#10136: Search for Map CRS coordinates
Description:
- resolve FE failure in unit test

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- fix issue of on focus effect in NumericInput

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- fix FE issue in onKeyDown in IntlNumberFormControl

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- revert unnecessary change

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- move the fixing logic of cursor position to componentDidUpdate instead of onKeyUp

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- add onKeyUp as a prop into IntlNumberFormControl for any expected future consuming from a parent comp

* geosolutions-it#10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- add unit test
- resolve review comments
@mahmoudadel54
Copy link
Collaborator Author

Test passed, @mahmoudadel54 please backport to 2024.01.xx. Thanks

Backport is done ---> #10346

dsuren1 pushed a commit that referenced this pull request May 21, 2024
…eld component (#10312) (#10346)

* #10289: Cursor position is shifted incorrectly in Localized number field component
Description:
- fix the jumping cursor to unexpected positions for localized numeric input

* #10289: Cursor position is shifted incorrectly in Localized number field component
Description:
- replace logic in updateDidMount to onKeyUp
- remove unused comments

* #10289: Cursor position is shifted incorrectly in Localized number field component
Description:
- remove unused method in IntlNumberFormControl

* #10136: Search for Map CRS coordinates
Description:
- resolve FE failure in unit test

* #10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- fix issue of on focus effect in NumericInput

* #10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- fix FE issue in onKeyDown in IntlNumberFormControl

* #10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- revert unnecessary change

* #10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- move the fixing logic of cursor position to componentDidUpdate instead of onKeyUp

* #10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- add onKeyUp as a prop into IntlNumberFormControl for any expected future consuming from a parent comp

* #10289: Cursor position is shifted incorrectly in Localized number field component [resolve review comments]
Description:
- add unit test
- resolve review comments
@ElenaGallo ElenaGallo removed the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label May 21, 2024
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.

Cursor position is shifted incorrectly in Localized number field component
3 participants