Skip to content

Commit

Permalink
scroll results into view when loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomEtc committed Oct 1, 2023
1 parent 55a965d commit c92d818
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/state-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,17 @@ export class RewiringAmericaStateCalculator extends LitElement {
},
});

override updated() {
if (
this._utilitiesTask.status === TaskStatus.COMPLETE &&
this._task.status === TaskStatus.COMPLETE
) {
// if the utility selector is shown, prefer to scroll there, otherwise scroll to at a glance:
const results = this.shadowRoot?.querySelector('#utility-selector, #at-a-glance');
results?.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}

override render() {
// If we have incentives loaded, use coverage.state from that to determine
// which state outline to show. Otherwise, look at the "tempState" override,
Expand Down
2 changes: 1 addition & 1 deletion src/state-incentive-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ const summaryBoxTemplate = (

const atAGlanceTemplate = (response: APIResponse) => {
return html`
<div class="grid-section">
<div class="grid-section" id="at-a-glance">
<h2 class="grid-section__header">Incentives at a glance</h2>
<div class="grid-4-2-1 grid-4-2-1--align-start">
${summaryBoxTemplate(
Expand Down
2 changes: 1 addition & 1 deletion src/utility-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const utilitySelectorTemplate = (
utilityOptions: OptionParam[],
onChange: (utilityId: string) => void,
) =>
html` <div class="utility-selector">
html` <div class="utility-selector" id="utility-selector">
<div class="utility-selector__map">
${stateInfo.icon()}
<h1 class="utility-selector__title">
Expand Down

0 comments on commit c92d818

Please sign in to comment.