Skip to content

Refactor indexable pages to query per scope#22406

Merged
leonidasmi merged 5 commits intofeature/llms-txt-phase-2from
656-clanky-behavior-around-the-page-dropdowns
Jul 8, 2025
Merged

Refactor indexable pages to query per scope#22406
leonidasmi merged 5 commits intofeature/llms-txt-phase-2from
656-clanky-behavior-around-the-page-dropdowns

Conversation

@igorschoester
Copy link
Copy Markdown
Contributor

@igorschoester igorschoester commented Jul 7, 2025

Context

  • Fix some quirks with the page dropdowns.

Summary

This PR can be summarized in the following changelog entry:

  • Fixes some quirks regarding the page dropdowns on the settings' LLMs.txt page.

Relevant technical choices:

The component uses its ID as scope to have its own query, status and results.
The global list is used to get the actual entities with the referral IDs (e.g. the scope stores the ids, not the pages).
Added a cleanup of the scope on unmount, this aborts any ongoing request and removes the scope from the store.

Now I could've just made this in the component instead of in the store. In the hope that it is useful for other places.
But it might be just polluting the global store with inner component data too 😅 Just trying something new I suppose.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Go to your llms.txt settings: /wp-admin/admin.php?page=wpseo_page_settings#/llms-txt
  • Enable the feature and manual page selection
  • Save
  • To add a significant delay in these request, add the following in your PHP:
    • If you need/want more time, adjust the number at sleep, it is in seconds
add_action( 'rest_request_before_callbacks', function ( $response, $handler, $request ) {
	if ( $request->get_route() === '/yoast/v1/available_posts' ) {
		sleep( 1 );
	}

	return $response;
}, 10, 3 );
  • Refresh the page
  • Open the network tab in your console and filter on fetch/XHR for some easy insights if the requests are actually done or not
  • Before the /available_posts?search=&_locale=user request finishes, click on an empty dropdown and confirm that you get a loading state with the Searching pages... message.
  • Verify when the request is done you see the list of pages
  • Slowly type in a field
  • Verify you see searching
  • When you stop typing and searching is done, it should show the pages or no pages found
  • Deselect the field without having made a page selection
  • Verify the field is the previously selected page
  • Select the field
  • Verify it show your query again only true if there is no selected page
  • Click the clear button
  • Verify it clears your query and starts searching again
  • Add the following under the sleep( 1 ); line, but still above the bracket } line:
    • This will make searching for foo error
		if ( $request->get_param('search') === 'foo' ) {
			return new Reponse(
				[
					'code'    => 'rest_page_invalid_id',
					'message' => 'Invalid page ID.',
					'data'    => [
						'status' => 400,
					],
				],
				400
			);
		}
  • Search for foo
  • Verify it has a Failed to retrieve pages. status indication when the request finished

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/reserved-tasks/issues/656

@igorschoester igorschoester added this to the feature/llms-txt-phase-2 milestone Jul 7, 2025
@igorschoester igorschoester added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Jul 7, 2025
@coveralls
Copy link
Copy Markdown

coveralls commented Jul 7, 2025

Pull Request Test Coverage Report for Build 6a28461c15e740ae122049bff5ca09d91b90aa2d

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 59 (0.0%) changed or added relevant lines in 2 files are covered.
  • 18 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.04%) to 53.576%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/js/src/settings/components/formik-indexable-page-select-field.js 0 16 0.0%
packages/js/src/settings/store/indexable-pages.js 0 43 0.0%
Files with Coverage Reduction New Missed Lines %
packages/js/src/settings/store/indexable-pages.js 2 0.0%
packages/js/src/settings/routes/llms-txt.js 16 0.0%
Totals Coverage Status
Change from base Build 19fd45952aca24fa50e6935224a9e7f266ee2ee4: -0.04%
Covered Lines: 30490
Relevant Lines: 57881

💛 - Coveralls

@igorschoester igorschoester force-pushed the 656-clanky-behavior-around-the-page-dropdowns branch from 5eb17a3 to eeffff5 Compare July 7, 2025 14:59
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 8, 2025

A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch.

The component uses its ID as scope to have its own query, status and results.
The global list is used to get the actual entities with the referral IDs (e.g. the scope stores the ids, not the pages).
Added a cleanup of the scope on unmount, this aborts any ongoing request and removes the scope from the store.
Taking precedence over the page name
But without focus just the page name
Not sure how to properly fix this yet
@igorschoester igorschoester force-pushed the 656-clanky-behavior-around-the-page-dropdowns branch from eeffff5 to da97bc9 Compare July 8, 2025 08:16
Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi left a comment

Choose a reason for hiding this comment

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

CR: 🏗️

A couple of remarks

Comment thread packages/js/src/settings/store/indexable-pages.js
Comment thread packages/js/src/settings/store/indexable-pages.js
Comment thread packages/js/src/settings/store/indexable-pages.js Outdated
Co-authored-by: Leonidas Milosis <leonidas.milossis@gmail.com>
Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi left a comment

Choose a reason for hiding this comment

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

CR + Acceptance is ✅

@leonidasmi leonidasmi merged commit f494d67 into feature/llms-txt-phase-2 Jul 8, 2025
22 checks passed
@leonidasmi leonidasmi deleted the 656-clanky-behavior-around-the-page-dropdowns branch July 8, 2025 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants