Bug - sp-textfield in latest Photoshop beta release

Reporting this bug to Adobe… I also reported this in the pre-release group but I never got a response so I am posting it here. It really isn’t a pre-release topic anyway.

In the latest beta release, sp-textfield returns the .value as what is actually displayed for the truncated text in the text field. For example, if the user entered “My Custom Text String” into the field, but it was too long and truncated to “My Custom Tex…” in the UI, the .value returned would be “My Entered Tex…” instead of the entire untruncated text string.

Is this something that is going to be fixed when CC 2022 goes into the main release?

This affects all of my plugins for the license key entry, as well as a few other things. So I really need to know if I have to create work-around versions prior to the CC 2022 main release. The work-around is the use sp-textarea instead of sp-textfield to allow textwrap and to prevent the text from ever truncating. With CC 2022 being on the horizon, I need to know how to proceed pretty soon.

Also, where is the best place to report bugs in UXP? Should they go into this forum or one of the other forums?

I’m finding sp-textfield much more problematic. Anytime I open an new interface with an sp-textfield element, including a dialog modal, Photoshop pre-release beta crashes. However, switching sp-textfield to sp-textarea doesn’t cause the problem. Although doing so completely messes up the UI layout. And excess textarea can’t be hidden inside a div element with overflow: hidden.

It’s like sp-textfield is not supported anymore.

1 Like

With CC 2022 release coming soon, I guess the only option is to use textarea until it is resolved. I was hoping to hear from Adobe before updating all of my plugins in case there was a fix coming prior to CC 2022 to avoid updating if it isn’t needed. It sounds like this will affect a lot of plugins.

I can’t imagine that sp-textfield is being deprecated because the HTML input field was already slated to be deprecated in the future. So that would leave nothing to use for an equivalent. Textarea would be an OK “band-aid” fix if the height could be further reduced but it seems like there is a minimum that it will allow.

I would really like feedback from Adobe for this bug because this is a pretty big looming issue on the horizon.

I’m thinking of recommending to my customers to NOT update to Ps 2022 if this remains an issue. It’s impossible to scale the height of sp-textarea to be less than something around 30 pixels. That won’t work in my UI.

I’ve had to do that in the past but it is customer service and tech support nightmare to have to tell users to not update Photoshop. If you have a large userbase then it ends up being non-stop tech support and customer complaints. Hopefully Adobe fixes it before the CC 2022 release.

The latest MAX build I’ve seen fixes the ellipsis & crashing issues.

There’s a couple of nagging issues w/ number fields though – it can be “fun” to get a decimal point in edge-wise. If you have that issue, the following buggy-fill can help you work around it. (Basically: it turns all number fields into text fields and then forces them to be numbers via some JS.)

// sp-textfield type=text is also slightly broken in 5.5.1, causing decimal points
// to be difficult to enter. If this bothers you, you may wish to implement this fix
// which replaces these fields with their text equivalent and adds some additional
// logic to enforce numeric values.
(function () {
  function fixNumericSpTextField() {
    if(require("uxp").versions.uxp.startsWith("uxp-5.5.1")) {
      const candidates = document.querySelectorAll("sp-textfield[type=number]");
      candidates.forEach(el => {
        el.setAttribute("type", "text");
        el.setAttribute("data-uxp-type", "number");
      });
    }
    document.addEventListener("input", evt => {
      const { target } = evt;
      if (target.tagName === "SP-TEXTFIELD") {
        if (target.getAttribute("data-uxp-type") === "number") {
          if (Number.isNaN(Number(target.value)) || target.value.indexOf(" ") > -1) {
            target.value = target.getAttribute("data-uxp-last-good-value") || "0";
          } else {
            target.setAttribute("data-uxp-last-good-value", target.value.trim());
          }
        }
      }
    });
    const timer = setInterval(() => {
      if (document._domClient) {
        console.log("sp-textfield[type=text] fix enabled");
        /* IMPORTANT: next line is internal stuff to make 
           sure we keep fixing up text fields as they 
           are added to the DOM.
           DO NOT USE _domClient OR frameAck FOR ANY 
           OTHER PURPOSE. */
        document._domClient.addEventListener("frameAck", fixNumericSpTextField);
        clearInterval(timer);
        fixNumericSpTextField();
      }
    }, 16);
  }
})();