Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use flexbox for input element instead of calculating width manually #36

Closed
wants to merge 3 commits into from

Conversation

juhana
Copy link

@juhana juhana commented Sep 16, 2019

The same as erkyrath/quixe#40, now in the right place hopefully

@erkyrath
Copy link
Owner

erkyrath commented Oct 1, 2019

The report from IFComp is that this fix caused problems in some games. (Change iftechfoundation/ifcomp#181 was reverted at iftechfoundation/ifcomp@c3eb8b8 .)

Comment from chat:

The problem is visible when applied to Steph Cherrywell’s game

@erkyrath
Copy link
Owner

erkyrath commented Oct 1, 2019

Screenshot (1)

Screenshot of problem with long paragraphs.

@juhana
Copy link
Author

juhana commented Oct 2, 2019

Oops, if flexbox is applied to every line then all spans inside the paragraph (whenever the style changes) act as a flexbox. I've amended the commit so that only the line with the input field is a flexbox.

In theory this would still break if there's a long prompt that doesn't fit on one line and it has different styles inside it, but I don't think that would happen in real life.

@erkyrath
Copy link
Owner

erkyrath commented Oct 2, 2019

thanks, I will take another look.

@curiousdannii
Copy link
Contributor

Okay, this fix looks like it works. Good work Juhana! I'll send this for the IFComp site.

But... I'm not sure I'm happy with the limitation that the line with input can't have multiple styles. That's sure to happen eventually.

I think I've found one solution which should handle that. With flex-wrap we can handle multi-line multi-span input paragraphs, with the input taking up the rest of the line. The complication is that we'd have to split up the existing spans by words into their own separate spans in order for flex-wrap to work. What do you think of that for a more reliable solution?

@juhana
Copy link
Author

juhana commented Oct 5, 2019

I'm personally not very enthusiastic about anything that requires a lot of JavaScript setup – might just as well use the old width calculation then. But it can't think of a much better option here. It might be possible to use a contenteditable span instead of an input element, which would also allow the input to wrap to a new line, but that would also need quite a bit of JS to get it right.

@erkyrath
Copy link
Owner

Filling in history: this is the cursor positioning bug discussed at https://intfiction.org/t/quixe-chrome-cursor-position/42413 , which derives from this chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1001438

@curiousdannii
Copy link
Contributor

They say they've fixed the bug, so it would be worth checking if this patch is still needed.

@erkyrath
Copy link
Owner

erkyrath commented Mar 29, 2020

I've just been checking, and I don't think it's needed. (Chrome 80.0.3987.149 on Mac.)

Also, the flexbox solution has problems when the prompt is very long, even if it's a single style span. I added a quick test case to sample-demo-full.html in the glkote repository -- enter "longprompt". The current code puts the input line in the right place, but the flexbox code doesn't.

I'm still interested in a pure-CSS solution to this, but I don't think it exists at present.

So, with all of that, I think this patch adds up to a "not needed". I apologize for the long delay in looking at it.

@erkyrath
Copy link
Owner

Closing (see comment above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants