Skip to content

Commit

Permalink
fix(masthead-search): define placeholder (#3997)
Browse files Browse the repository at this point in the history
### Related Ticket(s)

Refs #3884.

### Changelog

**New**

- Default placeholder in `<dds-masthead-search>`.
  • Loading branch information
asudoh authored Sep 18, 2020
1 parent d209fd9 commit 73aba66
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ class DDSMastheadComposite extends LitElement {
@property({ type: Boolean, reflect: true, attribute: 'open-search-dropdown' })
openSearchDropdown = false;

/**
* Value to display when the input has an empty `value`.
*/
@property()
searchPlaceholder?: string;

/**
* The user authentication status.
*/
Expand Down Expand Up @@ -271,6 +277,7 @@ class DDSMastheadComposite extends LitElement {
menuButtonAssistiveTextInactive,
language,
openSearchDropdown,
searchPlaceholder,
unauthenticatedProfileItems,
userStatus,
_loadSearchResults: loadSearchResults,
Expand Down Expand Up @@ -298,6 +305,7 @@ class DDSMastheadComposite extends LitElement {
input-timeout="${inputTimeout}"
language="${ifNonNull(language)}"
?open="${openSearchDropdown}"
placeholder="${ifNonNull(searchPlaceholder)}"
.currentSearchResults="${ifNonNull(currentSearchResults)}"
._loadSearchResults="${ifNonNull(loadSearchResults)}"
></dds-masthead-search-composite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { html, property, customElement, LitElement } from 'lit-element';
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
import ifNonNull from 'carbon-web-components/es/globals/directives/if-non-null.js';
import HybridRenderMixin from '../../globals/mixins/hybrid-render';
import ThrottedInputMixin from '../../globals/mixins/throttled-input';
import './masthead-search';
Expand Down Expand Up @@ -81,6 +82,12 @@ class DDSMastheadSearchComposite extends ThrottedInputMixin(HybridRenderMixin(Li
@property({ type: Boolean, reflect: true })
open = false;

/**
* Value to display when the input has an empty `value`.
*/
@property()
placeholder?: string;

/**
* The shadow slot this search UI should be in.
*/
Expand All @@ -104,9 +111,9 @@ class DDSMastheadSearchComposite extends ThrottedInputMixin(HybridRenderMixin(Li
}

renderLightDOM() {
const { active, currentSearchResults, open } = this;
const { active, currentSearchResults, open, placeholder } = this;
return html`
<dds-masthead-search ?active="${active}" ?open="${open}">
<dds-masthead-search ?active="${active}" ?open="${open}" placeholder="${ifNonNull(placeholder)}">
${currentSearchResults.map(
item =>
html`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class DDSMastheadSearch extends BXDropdown {
* Value to display when the input has an empty `value`.
*/
@property({ reflect: true })
placeholder = '';
placeholder = 'Search all of IBM';

/**
* The redirect URL when a user selects a search suggestion.
Expand Down

0 comments on commit 73aba66

Please sign in to comment.