Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment: Add lightbox to Image block using directives (reopened) (#…
…50373) * Add behaviors to the core theme.json * Add behaviors to json schemas for theme.json * Add a behaviors panel * Remove the changes to theme.json schema * Add behaviors to the VALID_SETTINGS in class-wp-theme-json-gutenberg.php * Add the first (still broken) version of the lightbox settings * WIP: Added a SelectControl for the behaviors * Format PHP * Format correctly again * Use the props.name when getting the behaviors * Add initial e2e tests * Update the withBehaviors description * Cleaned up behaviors.js * Update e2e tests to check visibility * Update core-blocks doc with behaviors attribute * Update fixtures with new lightbox attribute * Add a new theme for e2e tests * Change theme.json to include `settings.behaviors` * Remove default behavior value from block.json * Minor fix to the implementation * Add more e2e tests * Create a selector for behaviors * Add a filter to load behaviors on the server from the theme.json * Add behaviors on the top-level in core theme.json * Use the behaviors in the hooks * Update the comment * Update the comment in behaviors.js * Update fixtures and e2e * Prevent mobile test gutenberg error (temporary - not the best solution) * Add priority on filter * Fix php standards * Found a much better way to fix php tests * Small refactor * Add `behaviors` as an allowed key to BLOCK_EDITOR_SETTINGS * Move the behaviors to top level in the e2e test theme.json file * Rename the `behaviors` setting to `behaviorsUIEnabled` * Change "None" to "No behaviors" * Behaviors -> behavior * Fix redundant ternary * Improve the JSDoc for behaviors selector * Rename the test themes to make more sense * Remove definition of `behaviors` attribute in core/image * Change default value for `behaviors.lightbox` to false and update e2e tests accordingly * Change the way we get the data from `theme.json` and adjust e2e * Capitalize behaviors' labels * Move PHP code adding `theme.json` behaviors to `block-editor-settings` * Update comment * Remove the behaviors require from load.php * Revert "Update comment" This reverts commit fc812bc6c04e8b3c5c7fe3450c1e39d1dd6f6f3b. * Revert "Move PHP code adding `theme.json` behaviors to `block-editor-settings`" This reverts commit e8d16c8bb4977d1e27b758a067066a78fc21f794. * Remove the comment that was added previously * Update comments in `behaviors.php` * Add back the require_once in load.php * Use `settings.blocks.core/image.behaviors.lightbox` * Use `behaviors.blocks.core/image.lightbox` * Remove experimental setting for interactivity API * Add lightbox to image block First pass at adding lightbox. Note: Added custom implementation of Preact Portal because the children[0] declaration in the render method was erroneous and undefined, preventing it from working as expected. * Add logic for hiding lightbox on esc key press and overlay click * Improve styles and add note to add conditional for lightbox markup * Add editor UI and attribute for toggling lightbox * Remove image translation animation and add fade instead * Add accessibility; clean up styles; fix bug regarding ref in directives Cleaned up the PHP file a bit as I implemented standard accessibility for a lightbox. I changed names of attributes and properties to be clearer, as well as conslidated some CSS. Important to note: I fixed a bug with the directives wherein 'ref' was coming in as null due to how it was being passed in hooks.js. * Configure image to use new Interactivity API runtime included in Gutenberg * Remove viewScript from image config * Add Portal directive to Interactivity API runtime * Set scrim to site background color * Remove extraneous image CSS declaration * Improve aria labeling * Code cleanup; simplify syntax, consolidate code * Refactor code, remove event listeners, consolidate logic * Fix formatting in SCSS file * Change CheckboxControl to a ToggleControl; update API docs * Update wp_enqueue_script to correctly add interactivity runtime * Fix linter errors * Update to use core.image namespace * Pause closing of lightbox slightly when using the mousewheel * Rename portal directive to 'wp-body' and remove unused reference * Add internal dependencies flag; update comment * Remove extraneous code * Fix accessibility bug due to directives being defined incorrectly * Move enableLightbox declaration in block.json * Remove extraneous package.json declarations * Fix PHP indentation linter error * Revise package-lock.json to match trunk * Fix linter errors in portals.js * Update fixtures * Tests: Add e2e specs for Image block on the frontend * Disable lightbox by default * Add aria-role attribute to lightbox markup * Add tests * Update fixtures * Fix accessibility issues 1.) Changed 'aria-role' attribute to 'role' 2.) Moved lightbox close button to before modal content 3.) Remove logic for closing dialog with Tab key 4.) Move <img> outside of <button> element 5.) Add aria-labelledby attribute to dialog * Add focus trap * Label elements as 'inert' when lightbox is open * Update import of image interactivity scripts * Fix bug where interactivity only worked with admin enabled * Put lightbox rendering behind experimental flag * Add check for query selector and update tests * Update spacing in PHP file * Remove tick() and modify CSS * Update config based on behaviors UI and trunk changes * Remove extraneous code * Remove extraneous code and simplify variable name * Use core WordPress API for experiments flag * Clean up declarations * Fix PHP spacing * Remove `enableLightbox` * Remove defaultValue from image block.json * Update render_callback of core/image to use Behaviors UI * Fix e2e test: - Remove trailing `}` - Incorrectly assuming `"lightbox": true` * Remove 'inert' declarations for now * Add period to behaviors help text * Create selector for 'role' attribute * Update fixtures * Update comment * Clean up data-wp-island attribute * Readd mistakenly deleted line * Improve syntax of tests * Replace getByLabel() with getByRole() in some tests * Remove 'experiments' flag * Remove dependency on 'experiments' flag in tests * Revert "Remove dependency on 'experiments' flag in tests" This reverts commit 429ebbe. * Revert "Remove 'experiments' flag" This reverts commit cd0c9dd. * Change `aria-label` separator * Add back the experimental setting --------- Co-authored-by: Michal Czaplinski <mmczaplinski@gmail.com> Co-authored-by: Carlos Bravo <carlos.bravo@automattic.com> Co-authored-by: Grzegorz Ziolkowski <grzegorz@gziolo.pl> Co-authored-by: Mario Santos <santosguillamot@gmail.com> Co-authored-by: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com>
- Loading branch information
ac13b94
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in ac13b94.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5073745326
📝 Reported issues:
No Behaviors
should be the default as defined in the core theme.json #50923 in/test/e2e/specs/editor/various/behaviors.spec.js