Skip to content

Commit

Permalink
refactor: label calls to changedProperties on internal props with @State
Browse files Browse the repository at this point in the history


PiperOrigin-RevId: 616175246
  • Loading branch information
Extended Component Library Team authored and copybara-github committed Mar 15, 2024
1 parent f20fa1b commit c14d28d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/place_picker/place_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

// Placeholder for objectProperty (google3-only)
import {css, html, PropertyValues} from 'lit';
import {customElement, property, query, state} from 'lit/decorators.js';

Expand Down Expand Up @@ -255,13 +256,13 @@ export class PlacePicker extends BaseComponent {
private readonly autocomplete = new Deferred<Autocomplete>();

protected override willUpdate(changedProperties: PropertyValues) {
if (changedProperties.has('disableSearch') && this.disableSearch &&
this.focusController.isKeyboardNavigating &&
if (changedProperties.has(/* @state */ 'disableSearch') &&
this.disableSearch && this.focusController.isKeyboardNavigating &&
getDeepActiveElement() === this.searchButtonElement) {
this.clearButtonElement?.focus();
}
if (changedProperties.has('hideClearButton') && this.hideClearButton &&
this.focusController.isKeyboardNavigating &&
if (changedProperties.has(/* @state */ 'hideClearButton') &&
this.hideClearButton && this.focusController.isKeyboardNavigating &&
getDeepActiveElement() === this.clearButtonElement) {
this.inputElement?.focus();
}
Expand Down Expand Up @@ -318,7 +319,7 @@ export class PlacePicker extends BaseComponent {
const map = await this.getMapById(this.forMap);
map && this.bindTo(map);
}
if (changedProperties.has('valueInternal')) {
if (changedProperties.has(/* @state */ 'valueInternal')) {
this.dispatchEvent(new Event('gmpx-placechange'));
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/store_locator/store_locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import '../place_picker/place_picker.js';
import '../icon_button/icon_button.js';
import '../place_building_blocks/place_directions_button/place_directions_button.js';

// Placeholder for objectProperty (google3-only)
import {html, nothing} from 'lit';
import {customElement, property, query, state} from 'lit/decorators.js';
import {classMap} from 'lit/directives/class-map.js';
Expand Down Expand Up @@ -199,7 +200,7 @@ export class StoreLocator extends BaseComponent {
*/
protected override willUpdate(changedProperties: Map<string, unknown>) {
if (changedProperties.has('listings') ||
changedProperties.has('initialized')) {
changedProperties.has(/* @state */ 'initialized')) {
this.internalListings =
(this.listings ?? []).map((x) => this.createInternalListing(x));
this.listingDistances.clear();
Expand All @@ -210,12 +211,12 @@ export class StoreLocator extends BaseComponent {
// Perform map updates after the DOM has rendered, so the map element
// will exist.
if (changedProperties.has('listings') ||
changedProperties.has('initialized')) {
changedProperties.has(/* @state */ 'initialized')) {
this.updateBounds();
}

if ((changedProperties.has('mapOptions') ||
changedProperties.has('initialized')) &&
changedProperties.has(/* @state */ 'initialized')) &&
this.mapOptions) {
this.mapElement?.innerMap?.setOptions(this.mapOptions);
}
Expand Down

0 comments on commit c14d28d

Please sign in to comment.