Playlist block can't open the native media library

未关闭 适合新手
#940 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
mobile-dev

调研方向

从 useNativeMediaLibrary 开始,openMediaLibrary 桥接消息在这里构建,并追踪 Playlist 块的 multiple 值如何从 edit.jsx(multiple="add" 在 MediaPlaceholder 和 MediaReplaceFlow 上)到达那里。与 issue 中提到的原生解码器进行比较——iOS 上的 OpenMediaLibraryAction 和 Android 上的 parseMediaLibraryConfig——它们都期望一个 Boolean,并注意 onSelect 回调已经把 multiple 当作 truthy。在发送前将 multiple 规范化为 Boolean;完成意味着点击“Media Library”和“Add track”会打开选择器,并且所选音频会在两个平台上添加。

由索引模型根据 Issue 内容生成。

描述

[Type] Bug
Description

Choosing "Media Library" in a Playlist block should open the native media picker and add the selected audio to the playlist. Nothing happens instead, on both iOS and Android.

The Playlist block passes multiple="add" to MediaUpload. Upstream types this as boolean | 'add'. GutenbergKit forwards the string unchanged in the openMediaLibrary bridge message, but both native decoders expect a Boolean:

  • iOS: OpenMediaLibraryAction fails to decode. Before #917 this hit a fatalError and crashed the app. Since #917 the message is logged and dropped.
  • Android: parseMediaLibraryConfig throws on requireBoolean("multiple"), and the message is logged and dropped.

A likely fix is to normalize multiple to a Boolean in useNativeMediaLibrary before sending it, which covers both platforms. The onSelect callback already passes an array when multiple is truthy.

Step-by-step reproduction instructions
  1. Open the editor in a host app or the demo app.
  2. Insert a Playlist block.
  3. Tap "Media Library" in the placeholder, or "Add track" in the toolbar on an existing playlist.
  4. The media picker doesn't open. The native logs show a dropped openMediaLibrary message.
Screenshots, screen recording, code snippet
// @wordpress/block-library/src/playlist/edit.jsx
<MediaPlaceholder multiple="add" … />
<MediaReplaceFlow multiple="add" … />
Environment info

GutenbergKit trunk (@wordpress/block-library 12.2.0). The crash was reported on the iOS app's 27.5 beta, before #917.

Please confirm that you have searched existing issues in the repo.
  • Yes
主要语言
JavaScript
星标
29
派生
6
平均合并
2 天 1 小时
30 天内合并 PR
76

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wordpress-mobile/GutenbergKit 的其他 Issue

查看 wordpress-mobile/GutenbergKit 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。