Skip to content

Conversation

@esezen
Copy link
Contributor

@esezen esezen commented Dec 11, 2023

No description provided.

@esezen esezen marked this pull request as ready for review December 11, 2023 21:17
@esezen esezen requested a review from a team December 11, 2023 21:18
@mocca102
Copy link
Contributor

mocca102 commented Dec 26, 2023

@esezen This will need to be updated based on the introduced changes. It's using section.identifier which is deprecated in this PR.

attributes['data-cnstrc-recommendations-pod-id'] = section.identifier;

Also this

(section) => section.identifier === target.dataset.cnstrcRecommendationsPodId

@mocca102
Copy link
Contributor

I believe we need to add a type guard here. I believe this should work if (!isCustomSection(section))

(section) => section.identifier === target.dataset.cnstrcRecommendationsPodId

Screenshot 2023-12-26 at 10 13 21 PM

export interface CustomSection extends CustomSectionConfiguration {
data: Item[];
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above is becoming confusing, redundant and introduces unnecessary types that makes it hard to understand the different configs 😭
Screenshot 2023-12-26 at 10 58 14 PM

What do you think of adding a utility type

  • type WithData<T> = T & { data: Item[] };
  • export type Section = WithData<AutocompleteSectionConfiguration> | WithData<RecommendationsSectionConfiguration> | WithData<CustomSectionConfiguration>;

This will trim down types especially that they're not used out of this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against this change but the code you posted seems more confusing than what we have. It's shorter but it's more confusing. Let's talk about this today

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the names alone but add comments


if (type === 'autocomplete' || !type) {
if (config.identifier && !config.indexSection) {
return { ...config, indexSection: config.identifier };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add type: 'autocomplete' here when !type instead of making it required

Context https://github.com/Constructor-io/constructorio-ui-autocomplete/pull/112/files#r1436618676

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, I'm just not entirely sure how we would type it. Let's pair on it

@esezen esezen requested a review from mocca102 December 28, 2023 20:51
Copy link
Contributor

@mocca102 mocca102 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@esezen esezen merged commit 3ad2d46 into main Jan 3, 2024
@esezen esezen deleted the csl-2867-os-ui-autocomplete-section-configuration-option-updates branch January 3, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants