TextEditor
TextEditor copied to clipboard
Text is not selectable when in read-only mode
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