LearnNewsExamplesServices
Frontmatter
id3386
titlecomponent.Carousel: itemCls
stateClosed
labels
enhancementstale
assigneesDinkh
createdAtAug 10, 2022, 9:35 AM
updatedAtSep 14, 2024, 4:26 AM
githubUrlhttps://github.com/neomjs/neo/issues/3386
authortobiu
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtSep 14, 2024, 4:26 AM

component.Carousel: itemCls

Closed v8.1.0 enhancementstale
tobiu
tobiu commented on Aug 10, 2022, 9:35 AM

Hi Torsten,

I merged your PR. The itemClick logic seems to be copied from a list and feels a bit odd to me.

config:

        /**
         * Custom cls added to each item
         * This is only a single string
         *
         * @member {String|null} itemCls=null
         */
        itemCls: null,

domListeners:

            click: {
                fn      : me.onClick,
                delegate: '.neo-carousel-item',
                scope   : me
            }

i guess neo-carousel-item should be the itemCls

    onClick(data) {
        let me = this,
            item;

        if (data.path[0].id === me.id) {
            me.onContainerClick(data);
        } else {
            for (item of data.path) {
                if (item.cls.includes(me.itemCls)) {
                    me.onItemClick(item, data);
                    break;
                }
            }
        }
    }

since we delegate to a static itemCls => neo-carousel-item, the container click if case can never happen. the else case will only trigger in case a dev does set its custom iconCls on top of the default one.

tl-br: using neo-carousel-item as the default value for itemCls and polishing the onClick() logic feels needed.

thoughts?

tobiu added the enhancement label on Aug 10, 2022, 9:35 AM
tobiu assigned to @Dinkh on Aug 10, 2022, 9:35 AM