Skip to content

Conversation

@martinrajdl
Copy link
Contributor

@martinrajdl martinrajdl commented Jan 24, 2024

What this change include?

  • removes sentence cased classnames from section list items & moves to data-cnstrc-display-name
  • prefixes kebab cased classname like so cio-section-kebab-case-item-section
  • keeps main classname
    Before:
Screenshot 2024-01-24 at 17 16 33 After: Screenshot 2024-01-24 at 17 08 54 - removes unnecessary classname from section item Screenshot 2024-01-24 at 18 16 28
  • task also includes criteria to "Make sectionName camelcase" but it already is 🤔

Copy link
Contributor

@Mudaafi Mudaafi left a 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 sectionClassName sectionDisplayName as well to add clarity.

Comment on lines 222 to 223
// TODO: duplicate tests? these don't seem to run on npm run test-storybook
TypeSearchTermRenderSectionsCustomOrder.play = async ({ canvasElement }) => {
Copy link
Contributor

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.

@Mudaafi Mudaafi added the wip Work in progress label Jan 30, 2024
Comment on lines 136 to 138
default:
sectionName = section.indexSectionName;
sectionTitle = section.indexSectionName;
break;
Copy link
Contributor

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:

  1. Define an additional type that mimics AutocompleteConfiguration but with no type
  2. Empty the default clause here. Add an if-conditional above to check if type===undefined
  3. Assign the type during convertLegacyParametersAndAddDefaults in useCioAutocomplete (preferred)

I'll pull up a separate PR for this.

Copy link
Contributor

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

Copy link
Contributor

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'

@Mudaafi Mudaafi removed the wip Work in progress label Jan 31, 2024
@Mudaafi Mudaafi requested a review from a team January 31, 2024 00:22
@Mudaafi Mudaafi added the wip Work in progress label Feb 2, 2024
@Mudaafi Mudaafi added do not merge and removed wip Work in progress labels Feb 13, 2024

const { type, displayName } = section;
let sectionName = section.displayName;
const sectionListingType = isCustomSection(section)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

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?

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.

Styles not affected, Logic looks solid, just left two comments

@Mudaafi Mudaafi requested review from a team and mocca102 February 27, 2024 23:19
@Mudaafi
Copy link
Contributor

Mudaafi commented Feb 27, 2024

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

Copy link
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

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

LGTM!

@Mudaafi Mudaafi self-requested a review March 8, 2024 17:37
@Mudaafi Mudaafi merged commit 1f56823 into main Mar 18, 2024
@Mudaafi Mudaafi deleted the csl-3088-os-ui-autocomplete-fix-issue-with-conflicting-styles branch March 18, 2024 19:12
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.

5 participants