Skip to content

Commit da1d686

Browse files
authored
feat(default parameters): Add option to disable initial Lob logo and turn off delayed search by default (#22)
1 parent c4aeb76 commit da1d686

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

example/src/AddressFormDemo.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const AddressFormDemo = ({ apiKey }) => {
3939
onSelection={handleSelect}
4040
onSubmit={handleSubmit}
4141
submitLabel="Verify"
42+
disableLobLogo={true}
4243
styles={{
4344
'lob-submit': { width: '100%' }
4445
}}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"build": "microbundle-crl --no-compress --format modern,cjs --css inline",
1515
"start": "microbundle-crl watch --no-compress --format modern,cjs --css inline",
1616
"prepare": "run-s build",
17-
"lint-fix": "eslint . --fix",
17+
"lint:fix": "eslint . --fix",
1818
"test": "run-s test:unit test:lint test:build",
1919
"test:build": "run-s build",
2020
"test:lint": "eslint .",

src/AddressForm/AddressForm.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ global.fetch = mockPost
1313
describe('AddressForm', () => {
1414
it('renders correctly', async () => {
1515
// Mock fetch response
16-
mockPost.mockReturnValueOnce(
16+
mockPost.mockReturnValue(
1717
Promise.resolve({
1818
json: () => mockAutocompleteSuccessResponse
1919
})

src/Autocomplete.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ const Input = (props) => <components.Input {...props} isHidden={false} />
184184
* Callback function when the input value changes.
185185
* @param {onError?} onError - Callback function when we receive an API error.
186186
* @param {boolean} primaryLineOnly - When true, applying a suggestion updates the value of our
187+
* @param {boolean} disableLobLogo - When true, disables the Lob logo.
187188
* select component with only the primary line of the address instead of the complete address.
188189
*/
189190
const Autocomplete = ({
190191
addressComponentValues = {},
191192
apiKey,
192-
delaySearch = true,
193+
delaySearch = false,
193194
delayValue = 800,
195+
disableLobLogo = true,
194196
onSelection = () => {},
195197
onError = () => {},
196198
onInputChange = () => {},
@@ -331,7 +333,7 @@ const Autocomplete = ({
331333
inputValue={inputValue}
332334
options={autocompleteResults}
333335
controlShouldRenderValue={false}
334-
noOptionsMessage={poweredByLob}
336+
noOptionsMessage={!disableLobLogo ? poweredByLob : () => <div></div>}
335337
placeholder='Start typing an address...'
336338
value={selectValue}
337339
{...reactSelectProps}

src/Autocomplete.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ global.fetch = mockPost
1616
describe('Autocomplete', () => {
1717
it('renders correctly', async () => {
1818
// Mock fetch response
19-
mockPost.mockReturnValueOnce(
19+
mockPost.mockReturnValue(
2020
Promise.resolve({
2121
json: () => mockAutocompleteSuccessResponse
2222
})
@@ -61,7 +61,7 @@ describe('Autocomplete', () => {
6161

6262
it('fires callback functions as expected', async () => {
6363
// Mock fetch response
64-
mockPost.mockReturnValueOnce(
64+
mockPost.mockReturnValue(
6565
Promise.resolve({
6666
json: () => mockAutocompleteSuccessResponse
6767
})
@@ -106,7 +106,7 @@ describe('Autocomplete', () => {
106106

107107
it('handles errors as expected', async () => {
108108
// Mock fetch response
109-
mockPost.mockReturnValueOnce(
109+
mockPost.mockReturnValue(
110110
Promise.resolve({
111111
json: () => mockAutocompleteFailureResponse
112112
})

0 commit comments

Comments
 (0)