Skip to content

Language picker: localizedView permission filter is never applied (dead code) #3900

Description

@xIrusux

Summary

The language-selection picker's localizedView permission filtering is dead code — it never actually restricts the offered languages.

Details

PermissionBasedLanguageSelectionControlWithElementContext (assets/js/src/core/modules/element/components/language-selection/type/with-element-context.tsx) does:

const elementDraft = useElementDraft(...)
if ('permissions' in elementDraft) {
  const permissions = elementDraft.permissions ...
  // filter user.contentLanguages by permissions.localizedView
}

But useElementDraft (core/modules/element/hooks/use-element-draft.ts) returns { ...draft, element: draft.asset|dataObject|document, editorType, isLoading, isError } — permissions live under elementDraft.element.permissions (IElementDraft.permissions), not at the top level. So 'permissions' in elementDraft is always false, the filter branch never runs, and the control always offers all of the user's content languages regardless of the element's localizedView permission.

Impact

Anywhere PermissionBasedLanguageSelectionControl is used (grid column config, language comparison, etc.), languages the user has no localizedView permission for are still shown/selectable. This is a behaviour bug, not just cosmetic.

Suggested fix

Read elementDraft.element?.permissions?.localizedView (with the existing "default"/empty fallbacks). Because this changes the picker's behaviour across all element types, it should be done as its own change with QA against a user whose localizedView is narrower than their content languages — deliberately out of scope for the batch-edit multi-locale PR (#3899), which now uses user.contentLanguages directly (matching what the picker actually shows today).

Also noticed (separate, minor)

In the asset batch-edit modal (asset/listing/batch-actions/batch-edit-modal/batch-edit-modal.tsx), the error useEffect reads isFolderPatchError/folderPatchError but its dependency array is [isError, isFolderPatchSuccess], so a folder-patch failure may not be reported. Pre-existing; worth a small dependency-array fix.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Affected capability

None yet

Platform Version

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions