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

Fix: Page Attributes: Order field does not allow negative numbers #9803

Merged
merged 1 commit into from Sep 18, 2018

Conversation

Projects
None yet
4 participants
@jorgefilipecosta
Member

jorgefilipecosta commented Sep 11, 2018

Description

Fixes: #9254

Besides allowing the input of negative numbers we also applied some improvements:

  • We now use text control to deal with id generation for label/field promoting code reusability.
  • We use an input type of number allowing users to take advantage of the browser UI optimizations for number inputs.

To correctly allow the input of negative number where temporarily on the input we may have only the string '-' which is not a valid number and should not be stored as the page order, I felt the need to use the state as a temporary storage for the input.

How has this been tested?

I checked the UI is identical to the previous version (the only difference are the arrows the browser provides for number inputs).
I checked I can type negative numbers, 0 and positive numbers without any problem.

@cristian-e

This comment has been minimized.

Show comment
Hide comment
@cristian-e

cristian-e Sep 16, 2018

Contributor

Tested the code and works fine. Only integers are accepted.
Small css fix: replacing align-content: center; with align-items: center; will better align the label and input
1

Contributor

cristian-e commented Sep 16, 2018

Tested the code and works fine. Only integers are accepted.
Small css fix: replacing align-content: center; with align-items: center; will better align the label and input
1

@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Sep 18, 2018

Member

Hi @cristian-e, thank you for reviewing this PR. Your suggestion was applied 👍

Member

jorgefilipecosta commented Sep 18, 2018

Hi @cristian-e, thank you for reviewing this PR. Your suggestion was applied 👍

@jorgefilipecosta jorgefilipecosta requested review from jasmussen, kjellr and WordPress/gutenberg-core Sep 18, 2018

@jasmussen

Confirmed, this fixes it for me:

screen shot 2018-09-18 at 10 42 55

And the tests pass.

The code looks good to me, but if you feel it needs a sanity check, might need another set of eyes than mine.

@jorgefilipecosta jorgefilipecosta requested a review from WordPress/gutenberg-core Sep 18, 2018

@tofumatt

Tested locally and it worked for me!

@jorgefilipecosta jorgefilipecosta merged commit bd5910b into master Sep 18, 2018

2 checks passed

codecov/project 48.81% (+<.01%) compared to c28d2db
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jorgefilipecosta jorgefilipecosta deleted the fix/order-field-does-not-allow-for-negative-numbers branch Sep 18, 2018

@jorgefilipecosta jorgefilipecosta added this to the 4.0 milestone Sep 18, 2018

@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Sep 18, 2018

Member

Thank you for the reviews!

Member

jorgefilipecosta commented Sep 18, 2018

Thank you for the reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment