Skip to content

Commit

Permalink
Fix rendering of DAS interstitial components
Browse files Browse the repository at this point in the history
With the Ember update, when the will-destroy action is called
to check the element height, its height is already zero. That
seems strange but I didn’t look into it any further, as
using did-insert to store the element lets us check its height
before any other actions when a processing button is pressed.
  • Loading branch information
backspace committed Feb 26, 2021
1 parent d164824 commit 2263d71
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/app/components/das/recommendation-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
...attributes
data-test-task-group-recommendations
class='recommendation-card'
{{will-destroy this.recommendationCardDestroying}}
{{did-insert this.cardInserted}}
>

<h2 class="top overview inner-container">Resource Recommendation</h2>
Expand Down
22 changes: 18 additions & 4 deletions ui/app/components/das/recommendation-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default class DasRecommendationCardComponent extends Component {

@tracked activeTaskToggleRowIndex = 0;

element = null;

@tracked cardHeight;
@tracked interstitialComponent;
@tracked error;
Expand Down Expand Up @@ -166,9 +168,13 @@ export default class DasRecommendationCardComponent extends Component {

@action
accept() {
this.storeCardHeight();
this.args.summary
.save()
.then(() => this.onApplied.perform(), e => this.onError.perform(e))
.then(
() => this.onApplied.perform(),
e => this.onError.perform(e)
)
.catch(e => {
if (!didCancel(e)) {
throw e;
Expand All @@ -178,10 +184,14 @@ export default class DasRecommendationCardComponent extends Component {

@action
dismiss() {
this.storeCardHeight();
this.args.summary.excludedRecommendations.pushObjects(this.args.summary.recommendations);
this.args.summary
.save()
.then(() => this.onDismissed.perform(), e => this.onError.perform(e))
.then(
() => this.onDismissed.perform(),
e => this.onError.perform(e)
)
.catch(e => {
if (!didCancel(e)) {
throw e;
Expand Down Expand Up @@ -237,8 +247,12 @@ export default class DasRecommendationCardComponent extends Component {
}

@action
recommendationCardDestroying(element) {
this.cardHeight = element.clientHeight;
cardInserted(element) {
this.element = element;
}

storeCardHeight() {
this.cardHeight = this.element.clientHeight;
}
}

Expand Down

0 comments on commit 2263d71

Please sign in to comment.