TextEditor icon indicating copy to clipboard operation
TextEditor copied to clipboard

Text is not selectable when in read-only mode

Open zertrin opened this issue 9 years ago • 3 comments

The issue has been reported by isd in the #sandstorm IRC channel, and I've troubleshooted it.

Given the following grain which is shared as read-only: https://oasis.sandstorm.io/shared/4vrj4sIOFYy1iJfYKkvkqJGUTvBXLhb6CLODn-HQ2UF the text is not selectable in Firefox (and maybe other browsers, but I didn't try).

The problem comes from incorrect usage of the disabled attribute for the <textarea>. In readonly mode, the textarea has a disabled="" attribute, which not only makes the text non editable (which is the intended result), but also prevent selecting it (which is the problematic side-effect).

The disabled attribute is not the correct attribute to enforce "read-only" mode

The readonly attribute is the correct attribute to control that behavior.

Simply replacing disabled="" by readonly="true" would fix the issue.

The problematic code is there: https://github.com/rchrd2/TextEditor/blob/master/public/components/x-main.html#L71

zertrin avatar Apr 24 '16 14:04 zertrin

As an aside: it works fine in Chromium in my testing, so Richard, do make sure to test with Firefox as part of repro-ing the bug.

paulproteus avatar Apr 24 '16 15:04 paulproteus

Hi @zertrin and @paulproteus Thanks for the bug report and suggestion fix. I did not know that the disabled attribute disabled selecting the text, but this webpage confirms that that's the case:

readonly -- This Boolean attribute indicates that the user cannot modify the value of the control. Unlike the disabled attribute, the readonly attribute does not prevent the user from clicking or selecting in the control. The value of a read-only control is still submitted with the form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea

I'll update this code and push a new release asap.

rchrd2 avatar Apr 25 '16 06:04 rchrd2

This just got me when trying to copy/paste URLs @paulproteus sent me. Any ETA on this?

ocdtrekkie avatar Jun 01 '16 01:06 ocdtrekkie