Skip to content

Commit

Permalink
elyra-ai#1919 Scroll Alert into view in Common Properties when clicke…
Browse files Browse the repository at this point in the history
…d on an Alert Link (elyra-ai#1920)
  • Loading branch information
srikant-ch5 authored May 15, 2024
1 parent 8cb8260 commit 2dad65f
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class EditorForm extends React.Component {
this.visibleTearsheet = null;
this.defaultOpenTab = props.activeTab;
this.alertOpenTab = null;

this.scrollToAlert = false;
}


Expand All @@ -89,6 +89,18 @@ class EditorForm extends React.Component {
return true;
}

componentDidUpdate(prevProps) {
// Scroll to the selected accordion even when clicked from Alerts tab
if (this.scrollToAlert || prevProps.activeTab !== this.props.activeTab) {
const activeTabId = this.props.activeTab;
const activeTabElement = document.getElementsByClassName(`${activeTabId}`);
if (activeTabId && activeTabElement.length > 0) {
activeTabElement[0].scrollIntoView({ behavior: "smooth" });
}
this.scrollToAlert = false;
}
}

_getMessageCountForCategory(tab) {
if (!this.props.showAlertsTab) {
return null;
Expand Down Expand Up @@ -138,6 +150,7 @@ class EditorForm extends React.Component {
if (this.defaultOpenTab === this.alertOpenTab) {
this.defaultOpenTab = null;
}
this.scrollToAlert = true;
this.props.setActiveTab(control.parentCategoryId);
}

Expand Down Expand Up @@ -205,7 +218,7 @@ class EditorForm extends React.Component {
open={ this.defaultOpenTab === tab.group || this.alertOpenTab === tab.group }
onHeadingClick={this._showCategoryPanel.bind(this, tab.group)}
className={`${classNames("properties-category-content",
{ "show": categoryOpen })}`}
{ "show": categoryOpen }, tab.group)}`}
>
{panelItems}
{additionalComponent}
Expand Down

0 comments on commit 2dad65f

Please sign in to comment.