From: Revanshu Paliwal Date: Mon, 19 Sep 2022 10:24:46 +0000 (+0200) Subject: SONAR-17295 Fixing scroll issue when searching for saml related properties X-Git-Tag: 9.7.0.61563~201 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d6fb04c69835547a1145939f3c6590cb68ee14a9;p=sonarqube.git SONAR-17295 Fixing scroll issue when searching for saml related properties --- diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/SamlAuthentication.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/SamlAuthentication.tsx index 05a8a9b44bf..e0ccf340bfa 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/SamlAuthentication.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/SamlAuthentication.tsx @@ -87,19 +87,31 @@ class SamlAuthentication extends React.PureComponent< componentDidMount() { const { definitions } = this.props; const keys = definitions.map(definition => definition.key).join(','); + // Added setTimeout to make sure the component gets updated before scrolling + setTimeout(() => { + if (location.hash) { + this.scrollToSearchedField(); + } + }); this.loadSettingValues(keys); } componentDidUpdate(prevProps: SamlAuthenticationProps) { const { location } = this.props; - if (this.formFieldRef.current && prevProps.location.hash !== location.hash) { + if (prevProps.location.hash !== location.hash) { + this.scrollToSearchedField(); + } + } + + scrollToSearchedField = () => { + if (this.formFieldRef.current) { this.formFieldRef.current.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' }); } - } + }; onFieldChange = (id: string, value: string | boolean) => { const { settingValue, dirtyFields } = this.state;