Skip to content

fix: admin UI and community cloud fixes - #439

Merged
sheabunge merged 13 commits into
core-betafrom
fix/admin-ui-cloud-fixes/core
Aug 5, 2026
Merged

fix: admin UI and community cloud fixes#439
sheabunge merged 13 commits into
core-betafrom
fix/admin-ui-cloud-fixes/core

Conversation

@imantsk

@imantsk imantsk commented Aug 4, 2026

Copy link
Copy Markdown
Member

Admin UI and community cloud fixes, with matching test coverage.

Changes

  • Snippet preview modal: footer actions gain a re-entrancy-guarded working state, and the modal accepts an extraActions render slot for additional footer buttons.
  • Community cloud: selection checkboxes and select-all controls are limited to downloadable snippets in both card and table views via a shared utils/snippets/cloud.ts helper, with each view owning a single select-all control. The snippets table accepts optional selection state so it can render without bulk actions.
  • Cloud search results: card metadata (tags and modified date) renders correctly when tags are present.
  • Kebab menu: keyboard navigation no longer intercepts key presses inside form inputs, and the menu list gains vertical padding.
  • Snippets table: tag filter select gains an aria-label; empty snippet type counts no longer render a stray zero in the subnav.
  • Snippet editor: saving a new snippet replaces the history entry instead of pushing a second one.
  • Cloud snippet model: string fields coerce scalar values and fall back to an empty string for non-scalar values from remote responses.
  • E2e: navigating to the snippets admin page restores the table view when the persisted preference is set to cards; new specs cover settings tab switching and cloud download eligibility.

Verification

  • eslint, phpcs: clean.
  • Webpack build: successful.
  • PHPUnit: 145 tests, 337 assertions, 0 failures.

* `beginWorking` can reject re-entry within the same tick, before React
* re-renders with the disabled buttons.
*/
const useWorkingState = () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels incredibly over-engineered – why is this necessary over simply using a single state variable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single state variable cannot reject the second click of a double-click: state updates are asynchronous, so both clicks read isWorking === false before the re-render disables the buttons, and the action fires twice. The ref mirrors the state synchronously so beginWorking() can refuse re-entry within the same tick. Happy to simplify if there is a leaner pattern that covers that case.


const newUrl = buildUrl(window.CODE_SNIPPETS.urls.edit, { id: response.id })
window.history.pushState({}, document.title, newUrl)
window.history.replaceState({}, document.title, newUrl)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use replaceState instead of pushState? pushState feels more user-friendly given we are changing the page URL itself.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With pushState, pressing back after the first save returns to the add-snippet URL, which renders an empty editor for a snippet that now exists — saving again from there creates a duplicate. replaceState lets the edit URL take over the history entry, so back leads to the previous page instead of the stale form. Happy to switch it back if keeping the extra history entry is preferred.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah fair enough – I suppose that makes sense. Just looking for the best user behaviour here.

</>}
</span>
{count && <span className="subnav-count">{count}</span>}
{count ? <span className="subnav-count">{count}</span> : null}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not update this – && is cleaner.

>
{`${label} `}
<span className="count">{
// translators: %d: number of snippets in the current view.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure these comments need to be on the line beforehand.

Comment thread src/js/utils/snippets/cloud.ts Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels unnecessary to create a whole new utility file for one function.

@sheabunge
sheabunge merged commit 9fa5020 into core-beta Aug 5, 2026
9 checks passed
@imantsk
imantsk deleted the fix/admin-ui-cloud-fixes/core branch August 5, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants