diff --git a/content/patterns/combobox/examples/combobox-select-only.html b/content/patterns/combobox/examples/combobox-select-only.html index cc32f80ffa..abbfda5e3d 100644 --- a/content/patterns/combobox/examples/combobox-select-only.html +++ b/content/patterns/combobox/examples/combobox-select-only.html @@ -51,8 +51,8 @@

Example

-
+
Favorite Fruit
diff --git a/content/patterns/combobox/examples/css/select-only.css b/content/patterns/combobox/examples/css/select-only.css index 2f67d370ed..9bf2c1ae43 100644 --- a/content/patterns/combobox/examples/css/select-only.css +++ b/content/patterns/combobox/examples/css/select-only.css @@ -20,7 +20,7 @@ pointer-events: none; position: absolute; right: 16px; - top: 50%; + top: 65%; transform: translate(0, -65%) rotate(45deg); width: 12px; } @@ -49,9 +49,9 @@ .combo-label { display: block; - font-size: 20px; font-weight: 100; margin-bottom: 0.25em; + font-size: 1.2em; } .combo-menu { diff --git a/content/patterns/combobox/examples/js/select-only.js b/content/patterns/combobox/examples/js/select-only.js index 7afa863158..103d555cc5 100644 --- a/content/patterns/combobox/examples/js/select-only.js +++ b/content/patterns/combobox/examples/js/select-only.js @@ -170,6 +170,7 @@ function maintainScrollVisibility(activeElement, scrollParent) { const Select = function (el, options = []) { // element refs this.el = el; + this.labelEl = el.querySelector('.combo-label'); this.comboEl = el.querySelector('[role=combobox]'); this.listboxEl = el.querySelector('[role=listbox]'); @@ -194,6 +195,7 @@ Select.prototype.init = function () { this.comboEl.innerHTML = this.options[0]; // add event listeners + this.labelEl.addEventListener('click', this.onLabelClick.bind(this)); this.comboEl.addEventListener('blur', this.onComboBlur.bind(this)); this.listboxEl.addEventListener('focusout', this.onComboBlur.bind(this)); this.comboEl.addEventListener('click', this.onComboClick.bind(this)); @@ -240,6 +242,10 @@ Select.prototype.getSearchString = function (char) { return this.searchString; }; +Select.prototype.onLabelClick = function () { + this.comboEl.focus(); +}; + Select.prototype.onComboBlur = function (event) { // do nothing if relatedTarget is contained within listboxEl if (this.listboxEl.contains(event.relatedTarget)) {