Deprecation: #98168 - Binding context menu item to this
See forge#98168
Description
Due to historical reasons, a context menu item is bound to
this in its callback action
which was used to access the context menu item's
dataset. The invocation of assigned callback actions
is adapted to pass the
dataset as the 3rd argument.
Binding the context menu item to
this in the callback is now marked as deprecated.
Impact
Using
this in a context menu item callback will trigger a deprecated log entry in the browser's console.
Affected installations
All extensions providing custom context menu actions are affected.
Migration
To access data attributes, use the
dataset argument passed as the 3rd argument in the context menu callback action.
// Before
ContextMenuActions.renameFile(table, uid): void {
const actionUrl = $(this).data('action-url');
top.TYPO3.Backend.ContentContainer.setUrl(
actionUrl + '&target=' + encodeURIComponent(uid) + '&returnUrl=' + ContextMenuActions.getReturnUrl()
);
}
// After
ContextMenuActions.renameFile(table, uid, dataset): void {
const actionUrl = dataset.actionUrl;
top.TYPO3.Backend.ContentContainer.setUrl(
actionUrl + '&target=' + encodeURIComponent(uid) + '&returnUrl=' + ContextMenuActions.getReturnUrl()
);
}
Copied!