# Text object api bug?

**URL:** <https://forums.creativeclouddeveloper.com/t/text-object-api-bug/1338>\
**Category:** UXP Plugin API\
**Tags:** api-feedback\
**Created:** [October 18, 2019, 1:42pm UTC](https://forums.creativeclouddeveloper.com/t/text-object-api-bug/1338 "2019-10-18T13:42:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpryland](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/cpryland/32/1172_2.png) [@cpryland](https://forums.creativeclouddeveloper.com/u/cpryland)\
**Post date:** [October 18, 2019, 1:42pm UTC](https://forums.creativeclouddeveloper.com/t/text-object-api-bug/1338/1 "2019-10-18T13:42:53Z")

</div>

### Issue

A plugin setting text in a newly-created text object results in the object disappearing.

### Steps to reproduce

Create a new text frame, but don’t type anything.

Have a plugin use the `textNode.text = "anything"` to assign the currently-selected node’s text content.

### Expected Behavior

The text node’s content becomes `anything`.

### Actual Behavior

The text node disappears from the scene.

If you type anything before invoking the plugin (just a single character is enough), then the `.text` assignment works and replaces what you’ve typed.

Maybe stupid error on my part?

If it’s not, it’s a pretty serious bug or missing feature (call it what you like), because it means that a plugin can’t supply the contents of a newly-created text object.

---

<div class="post-metadata">

**Author:** ![pklaschka](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pklaschka/32/3162_2.png) [@pklaschka](https://forums.creativeclouddeveloper.com/u/pklaschka)\
**Post date:** [October 18, 2019, 2:28pm UTC](https://forums.creativeclouddeveloper.com/t/text-object-api-bug/1338/2 "2019-10-18T14:28:09Z")

</div>

In XD, empty text nodes, unfortunately, don’t exist. I remember this already being a topic in the prerelease before the MAX last year, which lead to the menu items not being accessible as long as the text node gets edited. I assume you now reach the plugin via the panel, in which it, prosumably, is accessible while editing text?

Basically, as soon as you leave the “edit text” mode of a text layer (e.g., by clicking on a plugin or anything else), it, if empty, gets deleted, meaning the `selection` will no longer include the (no removed) text layer…

---

<div class="post-metadata">

**Author:** ![cpryland](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/cpryland/32/1172_2.png) [@cpryland](https://forums.creativeclouddeveloper.com/u/cpryland)\
**Post date:** [October 18, 2019, 3:08pm UTC](https://forums.creativeclouddeveloper.com/t/text-object-api-bug/1338/3 "2019-10-18T15:08:28Z")

</div>

Right, so I guess I’m asking for a feature: if a nascent text node has its `.text` property assigned by a plugin, make it “real” just like typing would.

This would solve the problem of “maximum surprise” the user currently experiences with a plugin “typing” vs a human typing, where the object you’re standing on just disappears beneath your feet.

---

<div class="post-metadata">

**Author:** ![peterflynn](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/peterflynn/32/56_2.png) [@peterflynn](https://forums.creativeclouddeveloper.com/u/peterflynn)\
**Post date:** [October 22, 2019, 1:22am UTC](https://forums.creativeclouddeveloper.com/t/text-object-api-bug/1338/4 "2019-10-22T01:22:17Z")

</div>

The problem here is that most actions aren’t allowed while in text-edit mode (including running plugins), so the text-editing mode is automatically terminated _before_ your plugin gets run. You’ll see the same behavior if you, say, click the Shadow checkbox in XD’s properties panel while you are actively editing text that is still empty.

In the more common case where the text _isn’t_ blank, this is a lot less confusing: the Text node sticks around, and the action the user tried to do is applied to it as they expected.

---

<div class="post-metadata">

**Author:** ![cpryland](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/cpryland/32/1172_2.png) [@cpryland](https://forums.creativeclouddeveloper.com/u/cpryland)\
**Post date:** [October 22, 2019, 9:53am UTC](https://forums.creativeclouddeveloper.com/t/text-object-api-bug/1338/5 "2019-10-22T09:53:08Z")

</div>

Right, but what would be ideal is for the assignment of `.text` from a plugin to act exactly like the user typing something.

So I’m asking you to consider changing the UX of text-edit mode: if someone’s creating a text node but hasn’t typed anything, let at least panel plugins run and allow them to set content as a proxy for the user’s typing.
