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

Additional backtick added when writing code #4642

Closed
2 tasks
swissspidy opened this issue Jan 23, 2018 · 11 comments
Closed
2 tasks

Additional backtick added when writing code #4642

swissspidy opened this issue Jan 23, 2018 · 11 comments
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... Good First Issue An issue that's suitable for someone looking to contribute for the first time [Type] Bug An existing feature does not function as intended [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.

Comments

@swissspidy
Copy link
Member

Issue Overview

When adding backticks, text between them will be in a <code> tag. When I try to close the code tag by typing the second backtick, the code tag is closed, but the backtick is written as well.

Steps to Reproduce (for bugs)

  1. Type a backtick
  2. Press space (otherwise the backtick will be added to the next letter, e.g. à)
  3. Write some code
  4. Type another backtick
  5. Press space.
  6. Notice that the code block is closed but the backtick is appended to it.

I'm using Chrome 63 (stable) on macOS, with WordPress trunk.

Expected Behavior

  1. The code tag should preferably be added right away, not just when typing the second backtick.
  2. Typing the second backtick should just close

Current Behavior

The code tag is added too late and the backtick is appended erroneously

Screenshots / Video

Here's a demo video: https://cloudup.com/cdRaWfzWJL1

Related Issues and/or PRs

#703, #4290

Todos

  • Tests
  • Documentation
@swissspidy swissspidy added [Type] Bug An existing feature does not function as intended [Feature] Blocks Overall functionality of blocks [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable labels Jan 23, 2018
@danielbachhuber danielbachhuber added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Jan 23, 2018
@noisysocks
Copy link
Member

I'm struggling to reproduce this issue. What keyboard layout are you using, @swissspidy?

@swissspidy
Copy link
Member Author

Ah, right. I‘m using a (Swiss) German keyboard layout.

@Rahmon
Copy link
Contributor

Rahmon commented Jan 25, 2018

I couldn't reproduce this issue too. I'm using a pt_BR keyboard layout.

@swissspidy
Copy link
Member Author

I guess the big difference is that we use a QWERTZ keyboard layout, not QWERTY.

You'll find lots of examples (including the Swiss and the German keyboard layout) on Wikipedia: https://en.wikipedia.org/wiki/QWERTZ

It's important to note that we need to press two keys (shift + caret) to get a backtick and that the backtick will be added to the succeeding letter (example: à) unless you "cancel" by hitting space (example: `a).

@karmatosed karmatosed added this to the Merge Proposal milestone Jan 25, 2018
@jasmussen
Copy link
Contributor

Some GIFs:

There's an issue with a trailing backtick that gets added, though. Steps to reproduce:

  • Write some text. Place the caret before a word. Write a backtick.
  • Place the caret after the word. Write a backtick and note how the word is converted into a code element.
  • Move the caret with the arrow keys, notice how a trailing ` shows up.

backticks

A smaller issue that is perhaps related, you can't convert a word to code if you add the backticks from right to left:

backticksbackwards

@jasmussen jasmussen added the [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... label Feb 7, 2018
@mtias mtias added the [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked. label Mar 7, 2018
@mtias mtias modified the milestones: Merge Proposal, WordPress 5.0 Mar 7, 2018
@bobbingwide
Copy link
Contributor

I've got this problem with a UK English keyboard in 2.6.0
Additionally, there's no easy mechanism to clear the formatting if something goes wrong at the end of a paragraph.

You have to use Edit as HTML to fiddle about with the </code></p> tags. Typing something other than a space before the end p tag should fix it.

@designsimply
Copy link
Member

designsimply commented Jun 26, 2018

Tested and confirmed that when using backticks to convert text to code, with the Swiss German keyboard layout active, an extra backtick appears in Chrome after typing a closing backtick. In Firefox, an extra backtick does not appear but the space gets eaten. In Safari 😆

My testing steps:

  1. On macOS, go to System Preferences > Keyboard > Input Sources and add Swiss German.
  2. Switch to the Swiss German keyboard layout.
  3. Go to Posts > Add New and start typing into the body text.
  4. Type a backtick (note: press shift + caret).
  5. Type any text.
  6. Type another backtick.

Video: 1m13s
Seen at http://alittletestblog.com/wp-admin/post-new.php running WordPress 4.9.6 and Gutenberg 3.1.0 using Chrome 67.0.3396.87 and Firefox 60.0.2 on macOS 10.13.5. Also tested with Safari 11.1.1 on macOS 10.13.5 (not pictured).

screen shot 2018-06-26 at tue jun 26 11 08 42 am
Seen at http://alittletestblog.com/wp-admin/post.php?post=13833&action=edit running WordPress 4.9.6 and Gutenberg 3.1.0 using Firefox 60.0.2 on macOS 10.13.5.

@mtias
Copy link
Member

mtias commented Oct 23, 2018

This has stopped happening for me for some reason. @designsimply can you recheck the above test?

@ellatrix
Copy link
Member

@mtias That's because of the new rich text value. @swissspidy Could you confirm this works now? Closing as I can also not reproduce.

@swissspidy
Copy link
Member Author

I don't see any duplicate back ticks now, but I'd expect the cursor to be outside the code block after closing it.

Instead it stays inside the code tag and somehow the cursor is right in front of a character instead of after it:

screenshot 2018-10-31 at 15 45 19

@ellatrix
Copy link
Member

@swissspidy There's an issue for that: #11276.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... Good First Issue An issue that's suitable for someone looking to contribute for the first time [Type] Bug An existing feature does not function as intended [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.
Projects
None yet
Development

No branches or pull requests

10 participants