Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-search-field] Update search field focus indicator to standard dashed line #3834

Merged
merged 17 commits into from
Jul 26, 2023
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Please review [Terra\'s Internationalization documentation](https://engineering.
Contributing
</h2>

Please read through our [contributing guidelines](CONTRIBUTING.md). Included are directions for issue reporting and pull requests.
Please read through our [contributing guidelines](./CONTRIBUTING.md). Included are directions for issue reporting and pull requests.

<h2 id="local-development">
Local Development
Expand Down
3 changes: 3 additions & 0 deletions packages/terra-search-field/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Changed
* Updated focus indicators to be a standard dashed line.

## 3.83.0 - (June 14, 2023)

* Fixed
Expand Down
30 changes: 13 additions & 17 deletions packages/terra-search-field/src/SearchField.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
vertical-align: middle;
width: var(--terra-search-field-max-width, 16.5rem);

*:focus {
outline: var(--terra-search-field-focus-keyboard-outline, 2px dashed #000);
outline-offset: var(--terra-search-field-focus-keyboard-outline-offset, 1px);
}

.input-group {
display: inline-flex;
flex: 1 1 auto;
Expand All @@ -23,12 +28,12 @@
.input::-ms-reveal {
display: none;
}

.input::-webkit-search-cancel-button {
// Remove webkit search clear functionality
display: none;
}

.input::-webkit-search-decoration {
// Get rid of extra left-padding getting added in Safari for search fields
appearance: none;
Expand All @@ -47,7 +52,8 @@
}

&:focus {
border-color: var(--terra-search-field-button-focus-border-color, #26a2e5);
border-color: var(--terra-search-field-button-focus-border-color, transparent);
box-shadow: var(--terra-search-field-button-focus-box-shadow, none);
z-index: 1;
}
}
Expand Down Expand Up @@ -77,9 +83,8 @@
margin-top: var(--terra-search-field-button-margin-top, 0);

&:focus {
border-color: var(--terra-search-field-button-focus-border-color, #26a2e5);
box-shadow: var(--terra-search-field-button-focus-box-shadow, 0 0 1px 3px rgba(76, 178, 233, 0.5), 0 0 7px 4px rgba(76, 178, 233, 0.35));
outline: none;
border-color: var(--terra-search-field-button-focus-border-color, transparent);
box-shadow: var(--terra-search-field-button-focus-box-shadow, none);
z-index: 1;
}
}
Expand Down Expand Up @@ -153,18 +158,9 @@
&:focus {
background-color: var(--terra-search-field-input-focus-background-color, #fff);
background-size: auto;
border: var(--terra-search-field-input-focus-border, 1px solid #4cb2e9);
box-shadow: var(--terra-search-field-input-focus-box-shadow);
border: var(--terra-search-field-input-focus-border, 1px solid #dedfe0);
box-shadow: var(--terra-search-field-input-focus-box-shadow, none);
color: var(--terra-search-field-input-focus-color);
outline: none;

[dir=ltr] & {
box-shadow: var(--terra-search-field-input-focus-ltr-box-shadow);
}

[dir=rtl] & {
box-shadow: var(--terra-search-field-input-focus-rtl-box-shadow);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
--terra-search-field-input-margin-top: 0;
--terra-search-field-input-padding-right: 2.28571rem;
--terra-search-field-clear-active-background-color: #0c0d0e;
--terra-search-field-button-focus-border-color: #004c76;
--terra-search-field-clear-icon-height: 1.14286rem;
--terra-search-field-clear-icon-margin-top: -0.214285rem;
--terra-search-field-clear-icon-width: 1.14286rem;
Expand All @@ -24,7 +23,6 @@
--terra-search-field-button-margin-left: -1px;
--terra-search-field-button-margin-right: 0;
--terra-search-field-button-margin-top: 0;
--terra-search-field-button-focus-box-shadow: #004c76;

--terra-search-field-input-background-color: #222a2e;
--terra-search-field-input-border: 1px solid #181b1d;
Expand All @@ -51,13 +49,16 @@
--terra-search-field-input-placeholder-disabled-font-style: italic;

--terra-search-field-input-focus-background-color: #222a2e;
--terra-search-field-input-focus-border: 1px solid #004c76;
--terra-search-field-input-focus-box-shadow: 0 0 1px 3px #004c76, 0 0 7px 4px #004c76;
--terra-search-field-input-focus-border: 1px solid #181b1d;
--terra-search-field-input-focus-color: #b2b5b6;

--terra-search-field-input-focus-ltr-box-shadow: none;
--terra-search-field-input-focus-rtl-box-shadow: none;

// focus - keyboard
--terra-search-field-focus-keyboard-outline: 2px dashed #b2b5b6;
--terra-search-field-focus-keyboard-outline-offset: 1px;

@include terra-inline-svg-var('--terra-search-field-clear-icon-background-image', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="#b2b5b6" d="M24 0C10.7 0 0 10.7 0 24s10.7 24 24 24 24-10.7 24-24S37.3 0 24 0zm13.9 33.8l-2.1 2.1-1.2 1.2-1 .9-9.6-9.7-9.6 9.7-2.2-2.1-1.1-1.1-1-1 9.7-9.8-9.7-9.8 1-1 1.1-1.1 2.2-2.1 9.6 9.7 9.6-9.7 1 .9 1.2 1.2 2.1 2.1-9.7 9.8 9.7 9.8z"/></svg>');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
--terra-search-field-input-padding-right: 2.28571rem;
--terra-search-field-clear-active-background-color: transparent;
--terra-search-field-button-focus-border-color: #26a2e5;
--terra-search-field-focus-keyboard-outline: none;
--terra-search-field-focus-keyboard-outline-offset: none;
--terra-search-field-clear-icon-height: 1.14286rem;
--terra-search-field-clear-icon-margin-top: -0.214285rem;
--terra-search-field-clear-icon-width: 1.14286rem;
Expand Down Expand Up @@ -52,12 +54,9 @@

--terra-search-field-input-focus-background-color: #fff;
--terra-search-field-input-focus-border: 1px solid #4cb2e9;
--terra-search-field-input-focus-box-shadow: 0 0 8px #a6d9f4;
--terra-search-field-input-focus-box-shadow: inset 0 3rem 1.5rem -2rem #f4f4f4, 0 0 1px 1px rgba(255, 255, 255, 0.65), 0 0 2px 3px rgba(76, 178, 233, 0.5), 0 0 6px 4px rgba(76, 178, 233, 0.3);
--terra-search-field-input-focus-color: #1c1f21;

--terra-search-field-input-focus-ltr-box-shadow: 0 0 8px #a6d9f4;
--terra-search-field-input-focus-rtl-box-shadow: 0 0 8px #a6d9f4;

@include terra-inline-svg-var('--terra-search-field-clear-icon-background-image', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="#909496" d="M24 0C10.7 0 0 10.7 0 24s10.7 24 24 24 24-10.7 24-24S37.3 0 24 0zm13.9 33.8l-2.1 2.1-1.2 1.2-1 .9-9.6-9.7-9.6 9.7-2.2-2.1-1.1-1.1-1-1 9.7-9.8-9.7-9.8 1-1 1.1-1.1 2.2-2.1 9.6 9.7 9.6-9.7 1 .9 1.2 1.2 2.1 2.1-9.7 9.8 9.7 9.8z"/></svg>');
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 48 additions & 6 deletions packages/terra-search-field/tests/wdio/search-field-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with scrolled text', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('default scrolled text', { mismatchTolerance: 0.1 });
});
});
Expand All @@ -37,6 +38,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with text', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('block with text');
});
});
Expand Down Expand Up @@ -69,6 +71,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with text', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('placeholder with text');
});
});
Expand All @@ -90,6 +93,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
it('should clear the value', () => {
$('#searchfield [data-terra-search-field-button="Clear"]').click();

expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('default value clear');
});

Expand All @@ -98,6 +102,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with overwritten text', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('default value with overwritten text');
});
});
Expand All @@ -119,6 +124,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with unchanged text', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('value unchanged text');
});
});
Expand All @@ -131,7 +137,8 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with too short text', () => {
Terra.validates.element('minimum length too short text');
// mismatchTolerance set to 0.1 to account for subtle variances in the dotted line
Terra.validates.element('minimum length too short text', { mismatchTolerance: 0.1 });
});

it('should not search with the button', () => {
Expand All @@ -149,7 +156,9 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with long enough text', () => {
Terra.validates.element('minimum length with long enough text');
expect($('input[type="search"]').isFocused()).toBeTruthy();
// mismatchTolerance set to 0.1 to account for subtle variances in the dotted line
Terra.validates.element('minimum length with long enough text', { mismatchTolerance: 0.1 });
});
});

Expand All @@ -165,6 +174,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with long enough text', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('callback with long enough text');
});

Expand All @@ -174,7 +184,9 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with too short text', () => {
Terra.validates.element('callback with too short text');
expect($('input[type="search"]').isFocused()).toBeTruthy();
// mismatchTolerance set to 0.1 to account for subtle variances in the dotted line
Terra.validates.element('callback with too short text', { mismatchTolerance: 0.1 });
});
});

Expand All @@ -190,7 +202,9 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with typed text', () => {
Terra.validates.element('setting value typed');
expect($('input[type="search"]').isFocused()).toBeTruthy();
// mismatchTolerance set to 0.1 to account for subtle variances in the dotted line
Terra.validates.element('setting value typed', { mismatchTolerance: 0.1 });
});

it('should trigger search when cutting', () => {
Expand All @@ -201,6 +215,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field after cut operation', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('setting value cut');
});

Expand All @@ -210,6 +225,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field after paste operation', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('setting value paste');
});

Expand All @@ -218,12 +234,14 @@ Terra.describeViewports('Search Field', ['medium'], () => {
$('#searchfield').click();
browser.pause(2000);

expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('setting value programmatically');
});

it('should search with value on search button press', () => {
$('#searchfield > [data-terra-search-field-button="Search"]').click();

expect($('button[data-terra-search-field-button="Search"]').isFocused()).toBeTruthy();
Terra.validates.element('setting value search');
});
});
Expand All @@ -234,12 +252,14 @@ Terra.describeViewports('Search Field', ['medium'], () => {
it('should enter a letter', () => {
$('input').setValue('L');

expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('on change updated once');
});

it('should enter another letter', () => {
$('input').addValue('o');

expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('on change updated twice');
});
});
Expand All @@ -251,6 +271,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
$('input').click();
browser.keys('Enter');

expect($('button[data-terra-search-field-button="Search"]').isFocused()).toBeTruthy();
Terra.validates.element('search with enter default');
});
});
Expand All @@ -261,19 +282,23 @@ Terra.describeViewports('Search Field', ['medium'], () => {
it('should enter a search term', () => {
$('input').setValue('Lore');

Terra.validates.element('auto search disabled text before search');
expect($('input[type="search"]').isFocused()).toBeTruthy();
// mismatchTolerance set to 0.1 to account for subtle variances in the dotted line
Terra.validates.element('auto search disabled text before search', { mismatchTolerance: 0.1 });
});

it('should search with the button', () => {
browser.keys('Enter');

expect($('button[data-terra-search-field-button="Search"]').isFocused()).toBeTruthy();
Terra.validates.element('auto search disabled searched text');
});

it('should search using enter', () => {
$('input').addValue(' is spelled correctly');
browser.keys('Enter');

expect($('button[data-terra-search-field-button="Search"]').isFocused()).toBeTruthy();
Terra.validates.element('auto search disabled extended search');
});
});
Expand All @@ -289,10 +314,25 @@ Terra.describeViewports('Search Field', ['medium'], () => {
$('#search-field-focus-button').waitForDisplayed();
$('#search-field-focus-button').click();

expect($('input[type="search"]').isFocused()).toBeTruthy();
Terra.validates.element('focus with focus');
});
});

describe('Clear Button in Focus', () => {
before(() => browser.url('/raw/tests/cerner-terra-core-docs/search-field/minimum-length-search-field'));

it('should enter a search term', () => {
$('input').setValue('Lore');
browser.keys(['Tab']);
});

it('should focus clear button', () => {
expect($('button[data-terra-search-field-button="Clear"]').isFocused()).toBeTruthy();
Terra.validates.element('clear button focused');
});
});

describe('Delayed Search Field', () => {
before(() => browser.url('/raw/tests/cerner-terra-core-docs/search-field/delayed-search-field'));

Expand All @@ -304,7 +344,9 @@ Terra.describeViewports('Search Field', ['medium'], () => {
setTimeout(() => { input.addValue('L'); }, 250);
setTimeout(() => { input.addValue('L'); }, 250);

Terra.validates.element('empty search text');
expect($('input[type="search"]').isFocused()).toBeTruthy();
// mismatchTolerance set to 0.1 to account for subtle variances in the dotted line
Terra.validates.element('empty search text', { mismatchTolerance: 0.1 });
});
});
});
Loading