Gutenberg: [ Latest Posts ] Max. number of words control doesn't react to keyboard input

Created on 11 Apr 2020  路  5Comments  路  Source: WordPress/gutenberg

Describe the bug
The default value for excerpt display is 55 words. There are three methods available, it seems, to modify that number in the sidebar
1) Slider
2) up/down 1
3) Type in a new value.

The third method, typing in a new value, doesn't work.

To reproduce
Steps to reproduce the behavior:

  1. Insert Latest Posts block
  2. Open the Block settings sidebar
  3. Enable Post Content
  4. Check Excerpt
  5. Try modify the number of words displayed with the keyboard

Expected behavior
I would have expected that I would be able to modify the number by typing in the right value.

Screenshots
Screen Shot 2020-04-11 at 5 03 43 PM

Desktop (please complete the following information):

  • OS: [e.g. iOS] 10.15.3
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] 80.0.3987.163

Additional context
Gutenberg 7.8.1
WordPress 5.4

[Block] Latest Posts [Status] In Progress [Type] Bug

Most helpful comment

Just submitted a PR for the fix 馃檹
https://github.com/WordPress/gutenberg/pull/22084

All 5 comments

I tested this and can confirm this is a bug.

It鈥檚 happening because

<RangeControl
    min={ MIN_EXCERPT_LENGTH }
    max={ MAX_EXCERPT_LENGTH }
/>

has 10-100 set as lower and upper bounds. Whenever you try to go single digit it would prevent you from typing. Same goes when you exceed 100. I was thinking maybe to make it from 1-100 because it would make fixing ones easier and also maybe show a tooltip whenever an invalid number is typed. Also when should a fallback value be set? If there鈥檚 no lower bound, emptying the field is allowed, which currently automatically sets it to 50.

@kirilzh I seem to recall that the component previously had built-in logic which would allow for temporary "violations" of the validation. It was implemented in #12952, I believe (cc @jorgefilipecosta). It looks like the changes in the refactoring in #19916 removed some of the logic around this, perhaps inadvertently regressing this intended behavior:

https://github.com/WordPress/gutenberg/pull/19916/files#diff-d9d2996da619bb1351e858132191dbbeL51

cc @ItsJonQ

With a fix, it would be good to have some automated tests which verify this behavior, to avoid potential future regressions.

@aduth Thank you for the heads up! I wasn't aware of this use case. I'll look into it now!

Just submitted a PR for the fix 馃檹
https://github.com/WordPress/gutenberg/pull/22084

Was this page helpful?
0 / 5 - 0 ratings