Skip to content

Commit

Permalink
Fix Custom select control component dropdown arrow spacing (WordPress…
Browse files Browse the repository at this point in the history
…#22925)

* Add story for long option labels

* Fix to allow sufficient space for down arrow icon to the right of selected option text

* Update packages/components/src/custom-select-control/style.scss

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>

* Update packages/components/src/custom-select-control/style.scss

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>
  • Loading branch information
getdave and talldan authored Jun 5, 2020
1 parent e724276 commit 5340282
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
27 changes: 25 additions & 2 deletions packages/components/src/custom-select-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
component: CustomSelectControl,
};

const options = [
const defaultOptions = [
{
key: 'small',
name: 'Small',
Expand All @@ -31,5 +31,28 @@ const options = [
},
];
export const _default = () => (
<CustomSelectControl label="Font size" options={ options } />
<CustomSelectControl label="Font size" options={ defaultOptions } />
);

const longLabelOptions = [
{
key: 'reallylonglabel1',
name: 'Really long labels are good for stress testing',
},
{
key: 'reallylonglabel2',
name: 'But they can take a long time to type.',
},
{
key: 'reallylonglabel3',
name:
'That really is ok though because you should stress test your UIs.',
},
];

export const longLabels = () => (
<CustomSelectControl
label="Testing long labels"
options={ longLabelOptions }
/>
);
6 changes: 6 additions & 0 deletions packages/components/src/custom-select-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
position: relative;
text-align: left;

// For all button sizes allow sufficient space for the
// dropdown "arrow" icon to display.
&.components-custom-select-control__button {
padding-right: $icon-size;
}

&:focus:not(:disabled) {
border-color: $theme-color;
box-shadow: 0 0 0 ($border-width-focus - $border-width) $theme-color;
Expand Down

0 comments on commit 5340282

Please sign in to comment.