Skip to content

Commit

Permalink
Merge pull request #134 from alleyinteractive/fix/issue-133/double-pi…
Browse files Browse the repository at this point in the history
…nned-posts-cause-empty-slot

Issue-133: Posts pinned twice in same Query block cause empty slot at the end
  • Loading branch information
mogmarsh authored Feb 15, 2024
2 parents 2b5986c + 6373657 commit 429c4dc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `WP Curate` will be documented in this file.

## 1.6.3 - 2024-02-14

- Bug Fix: Selecting a post more than once in a Query block causes empty slots at the end.

## 1.6.2 - 2024-02-08

- Bug Fix: Add intentional spacing before PostPicker buttons.
Expand Down
4 changes: 4 additions & 0 deletions blocks/post/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export default function Edit({

const updatePost = (post: number | null) => {
const newPosts = [...posts];
// If the post is already in the list, remove it.
if (post !== null && newPosts.includes(post)) {
newPosts.splice(newPosts.indexOf(post), 1, null);
}
newPosts[index] = post;
// @ts-ignore
dispatch('core/block-editor').updateBlockAttributes(queryParentId, {
Expand Down
4 changes: 4 additions & 0 deletions blocks/query/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ export default function Edit({

const setManualPost = (id: number, index: number) => {
const newManualPosts = [...manualPosts];
// If the post is already in the list, remove it.
if (id !== null && newManualPosts.includes(id)) {
newManualPosts.splice(newManualPosts.indexOf(id), 1, null);
}
newManualPosts.splice(index, 1, id);
setAttributes({ posts: newManualPosts });
};
Expand Down
2 changes: 1 addition & 1 deletion wp-curate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Curate
* Plugin URI: https://github.com/alleyinteractive/wp-curate
* Description: Plugin to curate homepages and other landing pages
* Version: 1.6.2
* Version: 1.6.3
* Author: Alley Interactive
* Author URI: https://github.com/alleyinteractive/wp-curate
* Requires at least: 6.4
Expand Down

0 comments on commit 429c4dc

Please sign in to comment.