Skip to content

Commit

Permalink
Block pasting non-numeric values in progress and rating columns (#9581)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Bulczak committed Sep 28, 2022
1 parent 29c3849 commit b7ea8c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions examples/12.1.2/docs/react/demo/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const App = () => {
beforeRenderer={addClassesToRows}
afterGetRowHeader={drawCheckboxInRowHeaders}
afterOnCellMouseDown={changeCheckboxCell}
beforePaste={(data, coords) => {
const {startCol} = coords[0];
if ((startCol === 5 || startCol === 6) && isNaN(data[0] as any)) {
return false
}
}}
manualRowMove={true}
licenseKey="non-commercial-and-evaluation"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class ProgressBarRenderer extends BaseEditorComponent {

getRangeValue(value: string): string {
const numberValue = parseInt(value);
if (numberValue < 0 || !numberValue) {
if (numberValue < 0 || !numberValue ) {
return '0';
}
if (numberValue > 100) {
Expand Down
2 changes: 1 addition & 1 deletion examples/12.1.2/docs/react/demo/src/renderers/Stars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class StarsRenderer extends BaseEditorComponent {
}

return (
<div className="star htCenter">{"★".repeat(parseInt(this.props.value))}</div>
<div className="star htCenter">{"★".repeat(parseInt(this.getRangeValue(this.props.value)))}</div>
);
}
}

0 comments on commit b7ea8c3

Please sign in to comment.