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

feat(pagination): remove number input arrow visibility #4641

Merged
merged 3 commits into from Jan 31, 2022

Conversation

jpuzz0
Copy link
Contributor

@jpuzz0 jpuzz0 commented Jan 25, 2022

Closes: #4224

To test, navigate to the Pagination examples and verify when focusing on any page select input box that up/down arrows are not visible and you are still able to use keyboard up/down arrows to increment/decrement the count.

@patternfly-build
Copy link

patternfly-build commented Jan 25, 2022

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good! Left a couple of comments.

Also one more update needed - we calculate the width of that input with 2 variables:

  • --pf-c-pagination__nav-page-select--c-form-control--width-chars - the number of characters the input should show.
  • --pf-c-pagination__nav-page-select--c-form-control--width-base - the base width of the input including the estimated width of the arrows that were removed in this PR.

Now that the arrows are gone, we should update the calculation that creates space for them in the width of that input. Here's the block where those vars are defined:

--pf-c-pagination__nav-page-select--c-form-control--width-base: 3.5ch;
--pf-c-pagination__nav-page-select--c-form-control--width-chars: 2;
--pf-c-pagination__nav-page-select--c-form-control--Width: calc(var(--pf-c-pagination__nav-page-select--c-form-control--width-base) + (var(--pf-c-pagination__nav-page-select--c-form-control--width-chars) * 1ch));

FWIW we also do this in the number input, which may be good as a reference:

// form control
--pf-c-number-input--c-form-control--width-base: calc(var(--pf-global--spacer--sm) * 2); // element's padding
--pf-c-number-input--c-form-control--width-chars: 4;
--pf-c-number-input--c-form-control--Width: calc(var(--pf-c-number-input--c-form-control--width-base) + var(--pf-c-number-input--c-form-control--width-chars) * 1ch);

@@ -255,6 +255,19 @@ $pf-c-pagination--breakpoint-map: build-breakpoint-map();
}
}

// hide number input up/down arrow buttons
input[type="number"] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test adding these styles under the .pf-c-form-control selector below? That selector should target this element without the need to define input[...]

&::-webkit-inner-spin-button,
&::-webkit-outer-spin-button {
// stylelint-enable
appearance: none;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! We do this in number input using an older technique. Any interest in updating that as part of this PR, too? If not we can make that a separate issue:

// disable default number increment arrows
// stylelint-disable
-moz-appearance: textfield;
&::-webkit-outer-spin-button,
&::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
// stylelint-enable

@jpuzz0 jpuzz0 force-pushed the feat/remove-pagination-input-arrows branch from 42ebe49 to e3a19e8 Compare January 26, 2022 16:13
Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, appreciate the DRY approach, and it matches the number input. Though I am noticing that there isn't always space for the number of characters to show via the --width-chars in both components. For example, "20" doesn't show correctly:

Screen Shot 2022-01-26 at 1 54 28 PM

Screen Shot 2022-01-26 at 1 54 32 PM

Screen Shot 2022-01-26 at 1 54 23 PM

Screen Shot 2022-01-26 at 1 54 19 PM

Seems like we should look into that a bit and make a small adjustment - do you agree @mcarrano @mmenestr?

Also this is going to change the visual width of the input, and if a user was either depending on the arrows and/or customized the input width, this could cause a visual issue for them. Just want to verify that's OK @mcarrano @mmenestr

@@ -80,3 +80,15 @@
}
}
// stylelint-enable

%pf-remove-num-arrows {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I was going to suggest this but didn't want to overcomplicate things! Kudos for taking the initiative. 🔥

@mcarrano
Copy link
Member

@mcoker Interestingly, I don't see the problem in Firefox, but I do in Chrome. I definitely think we need to address this, although I'm wary of adding more width since we could have cases where a pagination control is used in a toolbar with tight spacing. But is it true that overall we are reducing the with of the input by this PR? In that case maybe add some width back?

@jpuzz0
Copy link
Contributor Author

jpuzz0 commented Jan 26, 2022

I will say that I didn't recognize this in the react example equivalent for pagination because it seems we're automatically setting the number count to what the max is, so entering 20 out of 4 wasn't an option there, so it was definitely overlooked.

Thanks to the help of @mcoker who pointed out the input border was causing this issue, and for providing the calculation itself, I think these should be all set now:
image
image

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @jeffpuzzo!! So much better!

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @jeffpuzzo !

@mcoker mcoker merged commit 85da047 into patternfly:main Jan 31, 2022
@patternfly-build
Copy link

🎉 This PR is included in version 4.172.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Remove up and down arrows for pagination direct input box
4 participants