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

post empty images array with user hits escape #4325

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dblatcher
Copy link
Contributor

@dblatcher dblatcher commented Sep 2, 2024

What does this change?

Adds an "key down" event listener to the document to post a message event to the parent window (IE, if the Grid is being used in an iframe, the window that has the iframe) representing an empty array of images when the user hits the "Escape" key.

The intent is to allow the Grid to communicate the event to the parent application in a way consistent with the messages posted to communicate the user selecting or creating one of more crops - there are currently different formats for data representing one crop (object with image and crop fields) and multiple crops (object with images field, which is an array of those objects ) - the "Escape" key event equates to "0x image crops selected".

Did consider haveing the parent application attach the listener, but because the parent application is not necessarily on the same domain as the Grid, it won't always be possible to for it to listen to event on the grid iframe's content window:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentWindow#description

issues

Some controls in the Grid use the escape key - if a user was using them within the Iframe and hit escape, it should only close the control, not the whole window. May need to look a way to check the UI state before emitting the 'close' event

How should a reviewer test this change?

There should be no effect when the Grid is running in its own window the message will be posted, when the escape key is pressed, but not listened to.

TO DO - testing plan for embedding applications:

  • composer
  • facia-tool
  • media-atom-maker
  • atom-workshop.

How can success be measured?

Embedding applications can react to the escape key when the Grid Iframe has focussed (usually by closing the dialog)

Who should look at this?

Tested? Documented?

  • locally by committer
  • locally by Guardian reviewer
  • on the Guardian's TEST environment
  • relevant documentation added or amended (if needed)

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.

1 participant