Skip to content

Commit

Permalink
fix: 🐛 not create label when text is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector committed Jan 21, 2022
1 parent 3cc518e commit 1ce2f3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/x6/src/registry/tool/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class CellEditor extends ToolsView.ToolItem<
const value = this.editor.innerText.replace(/\n$/, '') || ''
// set value
const setText = this.options.setText
if (typeof setText === 'function') {
if (value !== '' && typeof setText === 'function') {
FunctionExt.call(setText, this.cellView, {
cell: this.cell,
value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ export default class Example extends React.Component {
})

graph.on('cell:dblclick', ({ cell, e }) => {
const name = cell.isEdge() ? 'edge-editor' : 'node-editor'
cell.removeTool(name)
cell.addTools([
{
name: cell.isEdge() ? 'edge-editor' : 'node-editor',
name,
args: {
event: e,
},
Expand Down
4 changes: 3 additions & 1 deletion sites/x6-sites/examples/node/tool/demo/editable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ graph.addEdge({

graph.on('cell:dblclick', ({ cell, e }) => {
const isNode = cell.isNode()
const name = cell.isNode() ? 'node-editor' : 'edge-editor'
cell.removeTool(name)
cell.addTools({
name: isNode ? 'node-editor' : 'edge-editor',
name,
args: {
event: e,
attrs: {
Expand Down

0 comments on commit 1ce2f3f

Please sign in to comment.