-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Adds editing options for progress and rating columns in react demo. #9935
base: develop
Are you sure you want to change the base?
Conversation
Launch the local version of documentation by running: npm run docs:review fd074cddfcb0b92de89da80948dc700fd758b490 |
…dsontable into feature/issue-9581-demo
@krzysztofspilka to run the project, run the following commands in the repo root:
And open http://localhost:8080/ in your web browser |
@warpech thanks for help, I'm on it. |
@bulaj I can't tell much about the quality of the code, but from the UX/UI standpoint, there are some issues that we should fix before rolling this out. See the list below.
|
@krzysztofspilka 1 and 3 should be fixed now. |
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.
Partial review. @jansiegel we will need to finish this.
] | ||
]; | ||
export const data = [{ | ||
0: false, |
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.
This entry is super confusing, I think we need to refactor it or remove it (is it even used)?
@@ -46,24 +47,25 @@ const App = () => { | |||
beforeRenderer={addClassesToRows} | |||
afterGetRowHeader={drawCheckboxInRowHeaders} | |||
afterOnCellMouseDown={changeCheckboxCell} | |||
beforePaste={omitNonNumericPaste} |
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.
This is to achieve the following requirement:
I can paste non-numeric values to both the "Progress" and "Rating" columns, and apparently the renderer will try to handle them. Try pasting
12394-3841-34
. When you open the editor of such a cell it is empty.
I think that this implementation is not as good as it could be. The best way to disallow certain inputs is to use a validator function and allowInvalid: false
configuration option. This is how e.g. date picker does it.
…eature/issue-9581-demo
* improve React demo * improve React demo
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.
@maciejbo-handsontable
I'm not sure what is the exact scope of this PR. Could you list the requirements that are supposed to be met here?
The PR description mentions only making the progress
and rating
columns editable, but the PR you previously used to make changes was described vaguely as improve React demo
.
That being said, I've looked at the demo after the modifications introduced by the PR and found these:
- This PR modifies the data used in the example. After the changes, the dataset consists of list of 5 items duplicated five times. I don't think demos in other frameworks do that. Was this change intentional?
- The
Progress
column allows entering non-numeric data, which results in the progress bar being displayed as 100%. Works the same with pasted data. - The
Rating
column doesn't accept non-numeric data when editing but does accept pasted non-numeric data, which results in the cell being cleared. - The demo contains some logic which I'm assuming was meant to horizontally align the header contents, but it targets only columns
9
,10
and12
and there are no such columns in this example. - The state of the row header checkboxes is stored at
(row, "0")
coordinates, which I find a bit weird.
If any of them is outside this task's scope, let me know.
Hey, what I can say is I was asked to "finish this PR which title says >editing options for prgress and rating<" and with that being said I was trying not to touch what was not necessary.
With first paragraph being said - normally I wouldn't touch this thing, but I needed to implement some related stuff, so I changed this entire file cause in my opinion it would be easier to change in future 5 places instead of 50 - but now, cause of your next points, I brought previous version back.
If I understand your message correctly, the same thing exists in rest of demos also and was brought here by guy who started this thing before me - I wouldn't know what was the reason, maybe some hidden functionality. Without this part what I see still works, but need confirmation if I have to do something with that in this PR.
As above - If I understand your message correctly, the same thing exists in rest of demos also. Need confirmation if I have to do something with that in this PR.
Hey, that's true - I think they should be and they are unified already.
this need to be confirmed by @adamu-handsontable , but what I can say is that @krzysztofspilka tested this thing before pushing here and didn't raise this point. |
As a result of this task I'd like to have a ready-to-use example with editable Progress and Rating. I see that there are some changes which are not required to achieve it. The original PR was done some time ago and got probably outdated. Our basis is the current example.
|
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.
I think all my previous points have been addressed, but one of @adamu-handsontable's points is missing:
Progress bar should accept the range of Floats from 0 to 100. Ratings should accept Integers from 1 to 5.
So I'm approving this PR and passing the review of that one point to @adamu-handsontable .
export const ProgressBarRenderer = (props: HandsontableProps) => { | ||
if (props.cellProperties.valid !== false) { |
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.
@maciejbo-handsontable
I found one additional issue with the demo - when you pass invalid data for the progress bar or stars columns, they're not marked as invalid.
That happens because Handsontable doesn't trigger validation by default when loading data.
To get around it it, you can manually trigger the validator if it wasn't triggered already.
Take a look at my suggestion, and if you think it works all right, could you implement it for the stars renderer as well?
export const ProgressBarRenderer = (props: HandsontableProps) => { | |
if (props.cellProperties.valid !== false) { | |
export const ProgressBarRenderer = (props: HandsontableProps) => { | |
let isValid = props.cellProperties.valid; | |
// Run the validator for the cell at initialization. | |
if (isValid === void 0) { | |
(props.cellProperties.validator as Function)(props.value, (isValueValid: boolean) => { | |
isValid = isValueValid; | |
}); | |
} | |
if (isValid === true) { |
Let's skip the validation of stars and progress for now. We'll do that in a separate PR later if necessary. |
…baseRenderer calls in the custom renderers.
…dsontable into feature/issue-9581-demo
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.
I have some suggestions. I'll test example after changes in code.
if (cellProperties.instance.getDataAtRowProp(row, "0")) { | ||
const rowData = cellProperties.instance.getSourceDataAtRow(row) as RowObject; | ||
|
||
if (!!rowData?.checked) { |
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.
if (!!rowData?.checked) { | |
if (rowData?.checked !== true) { |
const rowData = this.getSourceDataAtRow(row) as RowObject; | ||
|
||
input.type = 'checkbox'; | ||
input.checked = !!rowData?.checked; |
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.
input.checked = !!rowData?.checked; | |
input.checked = rowData?.checked === true; |
export const MESSAGE = { | ||
BAD_VALUE: '#bad-value#' | ||
}; |
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.
Do we need to introduce this variable using object?
export const MESSAGE = { | |
BAD_VALUE: '#bad-value#' | |
}; | |
export const BAD_VALUE_MESSAGE = '#bad-value#'; |
// Run the validator for the cell at initialization. | ||
if (isValid === void 0) { | ||
(props.cellProperties.validator as Function)(props.value, (isValueValid: boolean) => { | ||
isValid = isValueValid; | ||
}); | ||
} |
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 same as in ProgressBar.tsx
.
// Run the validator for the cell at initialization. | ||
if (isValid === void 0) { | ||
(cellProperties.validator as Function)(value, (isValueValid: boolean) => { | ||
isValid = isValueValid; | ||
}); | ||
} |
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.
Maybe its worth to move up method, beyond the renderer declaration, to not repeat function creation and make it more clear by naming it. Suggestion up to you.
@wszymanski as discussed, you will be assigned to this task with someone else from the Dev team as reviewer. Please accept all your remarks to the code. Let's treat this as a work in progress, thanks. |
Context
Adds editing options for progress and rating columns in react demo.
How has this been tested?
Manually in browser.
Types of changes
Related issue(s):
Affected project(s):
handsontable
@handsontable/angular
@handsontable/react
@handsontable/vue
@handsontable/vue3
Checklist:
[skip changelog]