msyavuz commented on code in PR #35156:
URL: https://github.com/apache/superset/pull/35156#discussion_r2362921955
##########
superset-frontend/src/dashboard/components/gridComponents/TabsRenderer/TabsRenderer.tsx:
##########
@@ -85,35 +133,80 @@ const TabsRenderer = memo<TabsRendererProps>(
handleClickTab,
handleEdit,
tabBarPaddingLeft = 0,
- }) => (
- <StyledTabsContainer
- className="dashboard-component dashboard-component-tabs"
- data-test="dashboard-component-tabs"
- >
- {editMode && renderHoverMenu && tabsDragSourceRef && (
- <HoverMenu innerRef={tabsDragSourceRef} position="left">
- <DragHandle position="left" />
- <DeleteComponentButton onDelete={handleDeleteComponent} />
- </HoverMenu>
- )}
-
- <LineEditableTabs
- id={tabsComponent.id}
- activeKey={activeKey}
- onChange={key => {
- if (typeof key === 'string') {
- const tabIndex = tabIds.indexOf(key);
- if (tabIndex !== -1) handleClickTab(tabIndex);
- }
- }}
- onEdit={handleEdit}
- data-test="nav-list"
- type={editMode ? 'editable-card' : 'card'}
- items={tabItems}
- tabBarStyle={{ paddingLeft: tabBarPaddingLeft }}
- />
- </StyledTabsContainer>
- ),
+ onTabsReorder,
+ }) => {
+ const sensor = useSensor(PointerSensor, {
+ activationConstraint: { distance: 10 },
+ });
+
+ const onDragEnd = useCallback(
+ ({ active, over }: DragEndEvent) => {
+ if (active.id !== over?.id && onTabsReorder) {
+ const activeIndex = tabIds.findIndex(id => id === active.id);
+ const overIndex = tabIds.findIndex(id => id === over?.id);
+ onTabsReorder(activeIndex, overIndex);
+ }
+ },
+ [onTabsReorder, tabIds],
+ );
+
+ return (
+ <StyledTabsContainer
+ className="dashboard-component dashboard-component-tabs"
+ data-test="dashboard-component-tabs"
+ >
+ {editMode && renderHoverMenu && tabsDragSourceRef && (
+ <HoverMenu innerRef={tabsDragSourceRef} position="left">
+ <DragHandle position="left" />
+ <DeleteComponentButton onDelete={handleDeleteComponent} />
+ </HoverMenu>
+ )}
+
+ <LineEditableTabs
+ id={tabsComponent.id}
+ activeKey={activeKey}
+ onChange={key => {
+ if (typeof key === 'string') {
Review Comment:
Isn't the key always string?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]