ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
30.02k stars 3.26k forks source link

current implementation of readonly uses disabled semantics #3924

Open lukesmurray opened 4 years ago

lukesmurray commented 4 years ago

This stackoverflow post has a good summary of the differences between disabled and readonly.

I've summarized some of the expected behaviors for readonly and disabled html elements and the current behavior of slate when slate is in readonly mode.

focus tab navigation editable click
readonly yes yes no yes
disabled no no no no
slate readonly no no no no

I'm unfortunately implementing a lock based collaborative editor where the editor is in readonly and when you click on it you request a lock. Once you get the lock the editor becomes editable. The problem is the click event doesn't fire if the editor is in readonly mode.

Some of these issues could be easy to fix for example in onClick I think the isEventHandled just needs to be moved before readOnly.

https://github.com/ianstormtaylor/slate/blob/4c3e737dda95d5ab67a94af903b25512d926c7fe/packages/slate-react/src/components/editable.tsx#L575-L582

focus may be harder since getting focus looks like it causes side effects.

Anyway my issue is resolved by using mouseDown instead of click but I thought it would be worth reporting since this felt unexpected.

mmdonaldson commented 4 years ago

+1 I have a use case where when the editor is read only there are still certain elements which upon click drives a navigation panel outside the slate editor