Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure the navigation editor with correct __experimentalFetchLinkSuggestions #21873

Merged
merged 9 commits into from Apr 30, 2020

Conversation

adamziel
Copy link
Contributor

@adamziel adamziel commented Apr 24, 2020

Description

edit-navigation package configured the block editor without __experimentalFetchLinkSuggestions setting. This broke fetching suggestions when creating a new menu item. This PR ensures the setting is present.

Fixes #21620

As a side note - should this even be a setting? Any reason not to use the import directly in LinkControl?

How has this been tested?

Tested locally

Screenshots

Zrzut ekranu 2020-04-24 o 16 53 03

Types of changes

Non-breaking change

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • [] I've updated all React Native files affected by any refactorings/renamings in this PR.

@adamziel adamziel added [Type] Bug An existing feature does not function as intended [Block] Navigation Affects the Navigation Block labels Apr 24, 2020
@adamziel adamziel self-assigned this Apr 24, 2020
@adamziel
Copy link
Contributor Author

I am not sure about whether or not should I add export { default as __experimentalFetchLinkSuggestions } from './link-control/fetch-link-suggestions'; to plugins/gutenberg/packages/block-editor/src/components/index.native.js - I'd appreciate someone more knowledgable weighing in on that.

@adamziel adamziel added this to PRs in progress in Navigation editor Apr 24, 2020
@adamziel adamziel added the [Priority] High Used to indicate top priority items that need quick attention label Apr 24, 2020
@github-actions
Copy link

github-actions bot commented Apr 24, 2020

Size Change: +61 B (0%)

Total Size: 817 kB

Filename Size Change
build/annotations/index.js 3.62 kB -2 B (0%)
build/block-directory/index.js 6.23 kB -4 B (0%)
build/block-editor/index.js 106 kB +128 B (0%)
build/block-editor/style-rtl.css 10.2 kB +2 B (0%)
build/block-editor/style.css 10.2 kB +2 B (0%)
build/block-library/editor-rtl.css 7.03 kB -26 B (0%)
build/block-library/editor.css 7.03 kB -26 B (0%)
build/block-library/index.js 114 kB +1.28 kB (1%)
build/blocks/index.js 48.1 kB -1 B
build/components/index.js 179 kB -2 B (0%)
build/components/style-rtl.css 16.9 kB -8 B (0%)
build/components/style.css 16.9 kB -8 B (0%)
build/compose/index.js 6.66 kB +2 B (0%)
build/core-data/index.js 11.4 kB -1 B
build/data/index.js 8.44 kB +13 B (0%)
build/edit-navigation/index.js 4.05 kB +512 B (12%) ⚠️
build/edit-post/index.js 27.6 kB -190 B (0%)
build/edit-post/style-rtl.css 12.2 kB -121 B (0%)
build/edit-post/style.css 12.2 kB -122 B (1%)
build/edit-site/index.js 10.9 kB -126 B (1%)
build/edit-site/style-rtl.css 5.11 kB -151 B (2%)
build/edit-site/style.css 5.11 kB -147 B (2%)
build/edit-widgets/index.js 7.5 kB -831 B (11%) 👏
build/edit-widgets/style-rtl.css 4.67 kB -336 B (7%)
build/edit-widgets/style.css 4.66 kB -338 B (7%)
build/editor/index.js 43.6 kB +242 B (0%)
build/format-library/index.js 7.63 kB +311 B (4%)
build/keyboard-shortcuts/index.js 2.51 kB -3 B (0%)
build/list-reusable-blocks/index.js 3.12 kB +1 B
build/plugins/index.js 2.67 kB -1 B
build/redux-routine/index.js 2.85 kB +9 B (0%)
build/rich-text/index.js 14.8 kB +1 B
build/server-side-render/index.js 2.68 kB -1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.02 kB 0 B
build/api-fetch/index.js 4.08 kB 0 B
build/autop/index.js 2.82 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/style-rtl.css 760 B 0 B
build/block-directory/style.css 761 B 0 B
build/block-library/style-rtl.css 7.14 kB 0 B
build/block-library/style.css 7.14 kB 0 B
build/block-library/theme-rtl.css 683 B 0 B
build/block-library/theme.css 685 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/data-controls/index.js 1.29 kB 0 B
build/date/index.js 5.47 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 3.1 kB 0 B
build/edit-navigation/style-rtl.css 485 B 0 B
build/edit-navigation/style.css 485 B 0 B
build/editor/editor-styles-rtl.css 428 B 0 B
build/editor/editor-styles.css 431 B 0 B
build/editor/style-rtl.css 3.27 kB 0 B
build/editor/style.css 3.27 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 2.13 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/is-shallow-equal/index.js 710 B 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/media-utils/index.js 5.29 kB 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.4 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/primitives/index.js 1.5 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.28 kB 0 B
build/url/index.js 4.02 kB 0 B
build/viewport/index.js 1.84 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.18 kB 0 B

compressed-size-action

@@ -24,6 +24,7 @@
"dependencies": {
"@babel/runtime": "^7.9.2",
"@wordpress/a11y": "file:../a11y",
"@wordpress/api-fetch": "file:../api-fetch",
Copy link
Contributor

Choose a reason for hiding this comment

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

the block-editor is a generic JS package not dependent of any API or backend, it shouldn't have a dependency to api-fetch or WordPress in any way. I'm not sure I know a lot about the current issue being fixed here but I though I'd mention this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah that makes sense, thank you! I moved it to @wordpress/editor for now, but now @wordpress/edit-navigation depends on editor just for this one function. I wonder what would be the best place to import this from in both editor AND edit-navigation. I've been thinking about considering the two as disjoint use cases and just copying&pasting that function, but the ultimate expectation is to have the suggestion list work the same in both the editor and in nav-menus.php so I'd rather stick to imports.

Copy link
Contributor

Choose a reason for hiding this comment

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

I had a look through the packages and yeah, I'm not sure there is a good place. And my feedback here will probably leave you with more questions than answers.

The main problem with importing from editor is that I think the unused store for the editor package will be initialized as a side-effect of importing from the package:
https://github.com/WordPress/gutenberg/blob/master/packages/editor/src/store/index.js#L34

I don't think it's a massive issue, but that might be an argument towards duplicating.

I did wonder if core-data could be an option (it's already a dependency of edit-navigation via other packages), though core-data is very much built around state management as its central purpose, so this might entail changing it to a selector/resolver and storing the suggestions in the reduxy store.

Not sure whether there's a reason that it isn't implemented in that way to begin with (perhaps related to the caching behavior in core-data, or could just be an artifact of the chronology things were developed in).

All-in-all, I would probably duplicate the function and leave helpful comments above both functions pointing to one another and maybe consider adding unit tests.

Copy link
Contributor Author

@adamziel adamziel Apr 28, 2020

Choose a reason for hiding this comment

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

@talldan I just updated this PR to use a copy of that function. Travis fails because of some package-lock stuff that I will fix tomorrow - your review is highly appreciated!

@noisysocks noisysocks removed the [Priority] High Used to indicate top priority items that need quick attention label Apr 26, 2020
@adamziel adamziel force-pushed the fix/link-control-does-not-show-suggestions branch from 17c991f to 1a2c1d2 Compare April 27, 2020 10:42
Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

Looks good. I think this is the lowest friction way to fix, and it doesn't introduce anything that can't be easily tidied up later.

@talldan talldan merged commit e24adb5 into master Apr 30, 2020
Navigation editor automation moved this from PRs in progress to Done Apr 30, 2020
@talldan talldan deleted the fix/link-control-does-not-show-suggestions branch April 30, 2020 03:07
@github-actions github-actions bot added this to the Gutenberg 8.1 milestone Apr 30, 2020
Comment on lines -20858 to +20824
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz",
"resolved": false,
Copy link
Member

@aduth aduth Apr 30, 2020

Choose a reason for hiding this comment

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

Heya, these changes aren't expected and cause local changes when running npm install on the master branch. No fault intended, I just want to better understand how this might have happened, since it was my hope these issues would have been resolved with the changes introduced in #21306.

Could you tell me which version of NPM you're running locally? You can check by npm -v. Can you elaborate more on what lockfile issues you were remarking about in #21873 (comment) ?

Copy link
Member

Choose a reason for hiding this comment

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

Fixed in e110119.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious about how Travis is giving a ✅ for these changes as well. Incorrect package lock changes have slipped in a few times now.

Copy link
Member

@aduth aduth May 1, 2020

Choose a reason for hiding this comment

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

If it's the same as what I'd been debugging at #16157 (comment) , I think the issues with Travis are a combination of:

  • These are optional dependencies, and specifically in the Linux environment that Travis runs in, they are skipped.
  • NPM doesn't (didn't?) do a great job of verifying and updating lockfile for optional dependencies which are skipped, so it never produces the "local changes" we depend on for the Build Artifacts job.

Copy link
Contributor Author

@adamziel adamziel May 4, 2020

Choose a reason for hiding this comment

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

@aduth thank you for quickly spotting and fixing the issue! It's pretty interesting - if you take a look at the commit history on this PR, you'll see I've had some trouble with getting the package-lock.json check to work. What finally did the trick was a fresh clone of the repo, ensuring npm 6.14.4, and doing npm install on this fresh clone. As a result, we ended up with this "resolved": false line.

See these two commits specifically:

  • 1a2c1d2 - changed resolved to "" and Travis check failed - 👍
  • a7d3436 - changed resolved to false and Travis check succeeded - 👎

I am not sure why:

  1. My npm generated the wrong package-lock.json
  2. Travis happily accepted that

I am using Mac FWIW

Copy link
Member

Choose a reason for hiding this comment

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

Hm, strange indeed. I still think the reason why Travis is passing, based on the prior comment at #16157 (comment), is that node-pre-gyp is not installed in Linux. At least, it's a transitive dependency of fsevents, where fsevents is explicitly skipped:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

https://travis-ci.com/github/WordPress/gutenberg/jobs/325042262

I would have hoped that running the latest NPM would be enough for these sorts of issues to be avoided. I have noticed a few other cases lately where there seems to be a difference if running npm install with an existing node_modules vs. a fresh clone (e.g. #21994 (comment)). It sounds similar to what you describe. I'm not sure how best we could address this, other than assuming it's a bug in NPM and hoping for an upstream fix.

I had contemplated at one point if it might be a good idea to run this specific Travis job in a macOS environment, since it is an option:

https://docs.travis-ci.com/user/reference/osx/

I'd be worried though that it could still leave some variability of accuracy across other OS.

Copy link
Contributor Author

@adamziel adamziel May 5, 2020

Choose a reason for hiding this comment

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

@aduth if all these cases are about "resolved": false in package-lock.json, maybe testing for that would be a good workaround? As in cat package-lock.json | grep "resolved": false?

Copy link
Member

Choose a reason for hiding this comment

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

@adamziel That's an interesting idea, for sure. The issue almost always manifests itself this way [1]. There is some prior art here with processing git diff to account for some variance [2]. We could do something similar to check for these sorts of values in package-lock.json.


[1] In the past there's also been some inconsistencies in toggling between http and https, though I've seen less of those lately.

[2] Actually not sure if this specific script is even needed anymore.

Copy link
Member

Choose a reason for hiding this comment

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

@aduth if all these cases are about "resolved": false in package-lock.json, maybe testing for that would be a good workaround? As in cat package-lock.json | grep "resolved": false?

Proposed at #22237.

I forgot you had suggested a simple approach using grep. It can work, though the approach in #22237 actually validates against the expected structure of a package-lock.json. Maybe overkill, but the work's done already 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Type] Bug An existing feature does not function as intended
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

In the new Navigation screen LinkControl does not show suggestions
5 participants