-
Notifications
You must be signed in to change notification settings - Fork 419
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 issue for bug #452. Be able to delete / hit backspace on highligh… #473
Conversation
…ighlight when format attribute is enabled
Hey! Changelogs info seems to be missing or might be in incorrect format. |
src/number_format.js
Outdated
const deletedValues = lastValue.substr(start, end - start); | ||
const hasNonNumeric = !![...deletedValues].find((deletedVal, idx) => this.isCharacterAFormat(idx + start, lastValue)); | ||
|
||
// if it has, only remove the numeric portion | ||
if(hasNonNumeric) { | ||
const deletedValuePortion = lastValue.substr(start) | ||
const recordIndexOfFormatCharacters = {}; | ||
const resolvedPortion = []; | ||
[...deletedValuePortion].forEach((currentPortion, idx) => { | ||
if(this.isCharacterAFormat(idx + start, lastValue)){ | ||
recordIndexOfFormatCharacters[idx] = currentPortion; | ||
} else if (idx > deletedValues.length - 1) { | ||
resolvedPortion.push(currentPortion); | ||
} | ||
}) | ||
|
||
Object.keys(recordIndexOfFormatCharacters).forEach(idx => { | ||
if(resolvedPortion.length > idx){ | ||
resolvedPortion.splice(idx, 0, recordIndexOfFormatCharacters[idx]); | ||
} else { | ||
resolvedPortion.push(recordIndexOfFormatCharacters[idx]) | ||
} | ||
}) | ||
|
||
value = lastValue.substr(0, start) + resolvedPortion.join(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is the format character can have numeric value in itself.
This logic makes the assumption that there will be no numeric char on format itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment was misleading. I wasn't checking if the characters that were removed were numeric. I corrected it and also created unit test to back it up
… tests to back it up. Numeric format characters will still be maintained
src/number_format.js
Outdated
const hasNonNumeric = !![...deletedValues].find((deletedVal, idx) => this.isCharacterAFormat(idx + start, lastValue)); | ||
|
||
// if it has, only remove characters that are not part of the format | ||
if(hasNonNumeric) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasNonNumeric variable name is confusing as format char can have number as well. Can we rename it to formatGotDeleted.
…alue if formatting got deleted` test
Something wrong with your prettier. Can you pull code from main repo. There are some conflicts. |
My master was outdated, I had to fetch latest and fix merge issues |
Co-authored-by: Sudhanshu Yadav <[email protected]>
…t when format attribute is enabled
Describe the issue/change
There is an issue stated on #452 when a user highlights a group of values that has a format character that it won't delete those grouped values.
Describe the changes proposed/implemented in this PR
The change is to let user be able to delete these grouped values but retaining the format character.
Link Github issue if this PR solved an existing issue
#452
Please check which browsers were used for testing