React TabStrip - TabStripTab - Tabs with id property

1 Answer 109 Views
TabStrip
Jason
Top achievements
Rank 2
Iron
Iron
Iron
Jason asked on 20 Jul 2023, 08:04 PM

Greetings,

Is it possible to add an id property to each tab of the TabStrip for automation testing?

 

Thanks,

Jason Li

1 Answer, 1 is accepted

Sort by
1
Accepted
Konstantin Dikov
Telerik team
answered on 21 Jul 2023, 03:48 PM

Hi Jason,

Thank you for reaching out to us.

Currently the TabStripTab does not have an option for setting an "id" property. All of the available properties of the Tab component can be found in the following help topic:

What we can suggest as a solution is to get reference to the TabStripTab after the initialization of the TabStrip with JavaScript (within React.useEffect) and manually add the "id" attribute to the elements. You can use the "k-tabstrip-items" class name of the parent UL element of the tabs as main selector and then get the Tab elements with "k-item" class.

Hope this helps.

 

Regards,
Konstantin Dikov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!

Jason
Top achievements
Rank 2
Iron
Iron
Iron
commented on 21 Jul 2023, 08:03 PM

Hi Konstantin,

I'm trying to assign the id to the Kendo Menu component using the solution from above but I'm not getting the element property from the current reference. Please help, thanks!
Here is the partial code:

const menuRef = useRef(null);
  useEffect(() => {
    if (menuRef.current) {
      console.log(menuRef?.current)
      const menuInput =
        menuRef?.current?.element?.getElementsByClassName('k-menu')[0];
      menuInput?.setAttribute(
        'id',
        `action-${record.id}`
      );
    }
  }, []);

<Menu ref={menuRef}>
   <MenuItem
     text="Actions"
     data={rowOptions}
     contentRender={contentRender}
   />   
</Menu>

Konstantin Dikov
Telerik team
commented on 24 Jul 2023, 11:54 AM

Hi Jason,

I have tested the code in the following example and the "id" attribute is correctly set for the menu's wrapping element:

If the issue persists, please try to isolate it in stackblitz example, so we can debug it locally.

 

Tags
TabStrip
Asked by
Jason
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Konstantin Dikov
Telerik team
Share this question
or