ACS-11155: update conditional checks to use optional chaining (#11658)

- Modified several components to use optional chaining for safer property access, enhancing code robustness.
- Updated ESLint configuration to enforce stricter rules on the use of optional chaining.
- Adjusted tests to reflect changes in property access patterns.
This commit is contained in:
Denys Vuika
2026-02-17 09:13:57 +00:00
committed by GitHub
parent 7004f54821
commit 84affe9f37
10 changed files with 22 additions and 22 deletions
@@ -160,7 +160,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit {
}
apply(model: Partial<{ from: Date; to: Date }>, isValidValue: boolean, updateContext = true) {
if (isValidValue && this.id && this.context && this.settings && this.settings.field) {
if (isValidValue && this.id && this.context?.queryFragments && this.settings?.field) {
this.isActive = true;
const start = DateFnsUtils.utcToLocal(startOfMinute(model.from)).toISOString();
@@ -82,7 +82,7 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
}
submitValues(updateContext = true) {
if (this.hasValidValue() && this.id && this.context && this.settings && this.settings.field) {
if (this.hasValidValue() && this.id && this.context?.queryFragments && this.settings?.field) {
this.updateDisplayValue();
const fields = this.settings.field.split(',').map((field) => (field += ':'));
let query = '';
@@ -128,7 +128,7 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
private updateQuery(value: number | null, updateContext = true) {
this.context.filterRawParams[this.id] = value;
this.displayValue$.next(this.value ? `${this.value} ${this.settings.unit ?? ''}` : '');
if (this.id && this.context && this.settings && this.settings.field) {
if (this.id && this.context?.queryFragments && this.settings?.field) {
if (value === null) {
this.context.queryFragments[this.id] = '';
} else {
@@ -118,7 +118,7 @@ export class SearchTextComponent implements SearchWidget, OnInit {
}
this.displayValue$.next(value);
if (this.context && this.settings && this.settings.field) {
if (this.context?.queryFragments && this.settings?.field) {
this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : '';
if (updateContext) {
this.context.update();