crosswords-js icon indicating copy to clipboard operation
crosswords-js copied to clipboard

Stop using <input> fields

Open mmkal opened this issue 1 year ago • 3 comments

Hi again! A problem that crosswords-js (and some other HTML-based crossword software I've come across) has is that on iPhone, using an input field opts in to some unwanted functionality (it may also happen on Android). For example, when you tap on the current cell to switch from across to down, a popup appears offering for you to "Select" the text in the input:

image

Also, for users with dark mode enabled, Safari iOS automatically changes the input background to be dark, making the difference between light and dark cells almost invisible:

image

Both of these could be controlled for by using a div or span with a keypress listener. This is, I think, roughly what squares.io does:

squares.io:

image

The Guardian uses an input, but is somehow hiding it so it's not clickable. They use some kind of customised HTML tags to actually show the entered letter:

image

I think the squares.io approach would be easier! I'd be happy to submit a pull request making this change after #42 is in, if you'd be open to it @dwmkerr and @pvspain ?

(Side-note: the modified styling in the first couple of screenshots is taking advantages of the overridable CSS variables in #41!)

mmkal avatar Oct 12 '23 16:10 mmkal

(Side-note: the modified styling in the first couple of screenshots is taking advantages of the overridable CSS variables in #41!)

Nice. What's that font you're using? Very stylish!

pvspain avatar Oct 13 '23 02:10 pvspain

The suggestion makes sense sure I'd be happy for a PR!

dwmkerr avatar Oct 13 '23 19:10 dwmkerr

Hi @mmkal,

I've been thinking about the selectability of the inputs for a while. What you're proposing - using a <div> - may work. There is quite a bit of work to implement and test.

  • Three keyboard event handlers.
  • Rendering and styling within the element. Inputs have quite a few properties.
  • Accessibility issues to research.

pvspain avatar Oct 15 '23 12:10 pvspain