-
Notifications
You must be signed in to change notification settings - Fork 3
[CSL-3088] - fix issue with conflicting styles #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CSL-3088] - fix issue with conflicting styles #128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, thanks for working on this!
Since we're surfacing sectionTitle as data-cnstrc-display-name, lets add some tests to check for them as well. We should probably rename sectionTitle to sectionClassNamesectionDisplayName as well to add clarity.
| // TODO: duplicate tests? these don't seem to run on npm run test-storybook | ||
| TypeSearchTermRenderSectionsCustomOrder.play = async ({ canvasElement }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These do run but they're aren't using the Components we export. These classes are found in the /src/stories/Autocomplete/Hook/index.tsx#HooksTemplate. We should probably update them there to be consistent in terms of our docs.
| default: | ||
| sectionName = section.indexSectionName; | ||
| sectionTitle = section.indexSectionName; | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is (type) broken currently but we still need it. Sections can be one of type autocomplete | recommendations | custom, but the type on autocomplete is optional meaning it can be undefined.
There's two ways to fix this:
- Define an additional type that mimics
AutocompleteConfigurationbut with no type - Empty the default clause here. Add an if-conditional above to check if
type===undefined - Assign the type during
convertLegacyParametersAndAddDefaultsinuseCioAutocomplete(preferred)
I'll pull up a separate PR for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which part you mean "This is (type) broken currently"? @Mudaafi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mocca102 Might be my configuration, but since we've explicitly defined the type Section to be one of three things and the switch statement accounts for all three, the final default type is never. TS then throws the error Property 'indexSectionName' does not exist on type 'never'
|
|
||
| const { type, displayName } = section; | ||
| let sectionName = section.displayName; | ||
| const sectionListingType = isCustomSection(section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way we can get this from getSectionProps since this same logic is being duplicated
https://github.com/Constructor-io/constructorio-ui-autocomplete/pull/128/files#diff-7f1c987b478566cc9cf82a2afc2ee7a7a150ec6047a7801e0ac01c410f7ce453R218
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could. The reason why its included here is because we've rendered a separate div with the relevant classes in Line 154 so we kind of have to duplicate the logic to get the required values here.
Took a look at our history and it might be something we've included prior to creating getSectionProps so we might be good to omit this entirely from the story. @esezen would love to get your thoughts here since you touched it previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of passing this variable via getSectionProps itself, I thought getSectionProps is meant to contain only the attributes we're going to render into the HTML? I would be against adding something in specifically for our Storybook.
| ? 'custom' | ||
| : toKebabCase(section.indexSectionName || section.data[0]?.section || 'Products'); | ||
|
|
||
| let sectionTitle: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for sectionTitle. Is there a way we can get this from getSectionProps instead?
mocca102
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Styles not affected, Logic looks solid, just left two comments
|
Changes are now backwards compatible. I've documented the classnames we're discontinuing here: https://github.com/Constructor-io/constructorio-ui-autocomplete/wiki/%5BWIP%5D-V2-Migration-Guide |
esezen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
What this change include?
data-cnstrc-display-namecio-section-kebab-case-item-sectionBefore: