Bugfix: tags table-cell-type cannot be edited if its readOnly (#806)

* tags and badges:table-cell-type cannot be edited if its readOnly

* going backward for badge and badges type
This commit is contained in:
Arpit 2021-09-21 17:02:18 +05:30 committed by GitHub
parent c17b76e5ea
commit ab17ead153
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -266,7 +266,7 @@ export function Table({
if (Array.isArray(labels)) {
columnOptions.selectOptions = labels.map((label, index) => {
return { name: label, value: values[index] };
return { name: label, value: values[index]};
});
}
}
@ -432,6 +432,7 @@ export function Table({
return (
<div>
<Tags
readOnly={!column.isEditable}
value={cellValue}
onChange={(value) => {
handleCellValueChange(cell.row.index, column.key || column.name, value, cell.row.original);

View file

@ -1,6 +1,6 @@
import React, { useState } from 'react';
export const Tags = ({ value, onChange }) => {
export const Tags = ({ value, onChange, readOnly }) => {
value = value || [];
@ -30,9 +30,11 @@ export const Tags = ({ value, onChange }) => {
function renderTag(text) {
return <span className="col-auto badge bg-blue-lt p-2 mx-1 tag mb-2">
{text}
<span className="badge badge-pill bg-red-lt remove-tag-button" onClick={() => removeTag(text)}>
x
</span>
{!readOnly && (
<span className="badge badge-pill bg-red-lt remove-tag-button" onClick={() => removeTag(text)}>
x
</span>
)}
</span>;
}
@ -42,7 +44,7 @@ export const Tags = ({ value, onChange }) => {
return renderTag(item)
})}
{!showForm &&
{(!showForm && !readOnly) &&
<span className="col-auto badge bg-green-lt mx-1 add-tag-button" onClick={() => setShowForm(true)}>{'+'}</span>
}