box-annotations 4.1.1-beta.2 → 4.1.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/i18n/en-US.js CHANGED
@@ -4,6 +4,7 @@ export default {
4
4
  "ba.annotationsLoadError": "We’re sorry, the annotations failed to load for this file.",
5
5
  "ba.annotationsPost": "Post",
6
6
  "ba.annotationsSave": "Save",
7
+ "ba.popup.reply.comment": "Comment",
7
8
  "ba.popups.cancel": "Cancel",
8
9
  "ba.popups.drawing.addComment": "Add Comment",
9
10
  "ba.popups.drawing.delete": "Delete",
@@ -8,6 +8,8 @@ ba.annotationsLoadError = We’re sorry, the annotations failed to load for this
8
8
  ba.annotationsPost = Post
9
9
  # Label for the save button
10
10
  ba.annotationsSave = Save
11
+ # Aria label description for reply popup
12
+ ba.popup.reply.comment = Comment
11
13
  # Button label for cancelling the creation of a description, comment, or reply
12
14
  ba.popups.cancel = Cancel
13
15
  # Button label for adding a comment in the drawing toolbar
@@ -1 +1 @@
1
- [{"id":"ba.popups.cancel","description":"Button label for cancelling the creation of a description, comment, or reply","defaultMessage":"Cancel"},{"id":"ba.popups.post","description":"Button label for creating a description, comment, or reply","defaultMessage":"Post"},{"id":"ba.popups.drawing.addComment","description":"Button label for adding a comment in the drawing toolbar","defaultMessage":"Add Comment"},{"id":"ba.popups.drawing.delete","description":"Button title for deleting a staged drawing","defaultMessage":"Delete"},{"id":"ba.popups.drawing.redo","description":"Button title for redoing a staged drawing","defaultMessage":"Redo"},{"id":"ba.popups.drawing.undo","description":"Button title for undoing a staged drawing","defaultMessage":"Undo"},{"id":"ba.popups.replyField.placeholder","description":"Placeholder for reply field editor","defaultMessage":"Type a comment..."},{"id":"ba.popups.popupHighlight.promoter","description":"Popup message for highlight promoter","defaultMessage":"Highlight and Comment"},{"id":"ba.popups.popupHighlight.restrictedPrompt","description":"Prompt message when selection crosses multiple pages","defaultMessage":"Comments restricted to single page"},{"id":"ba.popups.popupList.prompt","description":"Prompt message for empty popup list","defaultMessage":"Mention someone to notify them"},{"id":"ba.popups.popupCursor.regionPrompt","description":"Prompt message following cursor in region annotations mode","defaultMessage":"Draw a box to comment"}]
1
+ [{"id":"ba.popup.reply.comment","description":"Aria label description for reply popup","defaultMessage":"Comment"},{"id":"ba.popups.cancel","description":"Button label for cancelling the creation of a description, comment, or reply","defaultMessage":"Cancel"},{"id":"ba.popups.post","description":"Button label for creating a description, comment, or reply","defaultMessage":"Post"},{"id":"ba.popups.drawing.addComment","description":"Button label for adding a comment in the drawing toolbar","defaultMessage":"Add Comment"},{"id":"ba.popups.drawing.delete","description":"Button title for deleting a staged drawing","defaultMessage":"Delete"},{"id":"ba.popups.drawing.redo","description":"Button title for redoing a staged drawing","defaultMessage":"Redo"},{"id":"ba.popups.drawing.undo","description":"Button title for undoing a staged drawing","defaultMessage":"Undo"},{"id":"ba.popups.replyField.placeholder","description":"Placeholder for reply field editor","defaultMessage":"Type a comment..."},{"id":"ba.popups.popupHighlight.promoter","description":"Popup message for highlight promoter","defaultMessage":"Highlight and Comment"},{"id":"ba.popups.popupHighlight.restrictedPrompt","description":"Prompt message when selection crosses multiple pages","defaultMessage":"Comments restricted to single page"},{"id":"ba.popups.popupList.prompt","description":"Prompt message for empty popup list","defaultMessage":"Mention someone to notify them"},{"id":"ba.popups.popupCursor.regionPrompt","description":"Prompt message following cursor in region annotations mode","defaultMessage":"Draw a box to comment"}]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "box-annotations",
3
- "version": "4.1.1-beta.2",
3
+ "version": "4.1.1-beta.4",
4
4
  "description": "Box Annotations",
5
5
  "author": "Box (https://www.box.com/)",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -107,6 +107,7 @@
107
107
  "stylelint-config-rational-order": "^0.1.2",
108
108
  "stylelint-config-standard": "^19.0.0",
109
109
  "stylelint-order": "^3.1.1",
110
+ "tabbable": "^1.1.3",
110
111
  "typescript": "^3.8.3",
111
112
  "uglifyjs-webpack-plugin": "^2.2.0",
112
113
  "uuid": "^8.3.1",
@@ -30,3 +30,13 @@
30
30
  @include box-sizing;
31
31
  @include common-typography;
32
32
  }
33
+
34
+ .ba-Layer--drawing,
35
+ .ba-Layer--highlight,
36
+ .ba-Layer--region {
37
+ z-index: 3;
38
+ }
39
+
40
+ .ba-Layer--popup {
41
+ z-index: 4;
42
+ }
@@ -84,6 +84,7 @@ export default function PopupHighlight({ onCancel = noop, onSubmit = noop, shape
84
84
  >
85
85
  <button
86
86
  ref={buttonRef}
87
+ aria-haspopup="dialog"
87
88
  className="ba-PopupHighlight-button"
88
89
  data-testid="ba-PopupHighlight-button"
89
90
  onClick={onSubmit}
@@ -1,6 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import * as Popper from '@popperjs/core';
3
3
  import * as ReactRedux from 'react-redux';
4
+ import { useIntl } from 'react-intl';
5
+ import FocusTrap from 'box-ui-elements/es/components/focus-trap/FocusTrap';
6
+ import messages from './messages';
4
7
  import PopupBase from './PopupBase';
5
8
  import ReplyForm from '../ReplyForm';
6
9
  import usePrevious from '../../common/usePrevious';
@@ -83,6 +86,7 @@ export default function PopupReply({
83
86
  value = '',
84
87
  ...rest
85
88
  }: Props): JSX.Element {
89
+ const intl = useIntl();
86
90
  const popupRef = React.useRef<PopupBase>(null);
87
91
  const popupOptions = React.useRef<Partial<Popper.Options>>(getOptions()); // Keep the options reference the same between renders
88
92
  const rotation = ReactRedux.useSelector(getRotation);
@@ -99,14 +103,23 @@ export default function PopupReply({
99
103
  }, [popupRef, prevRotation, prevScale, rotation, scale]);
100
104
 
101
105
  return (
102
- <PopupBase ref={popupRef} data-resin-component="popupReply" options={popupOptions.current} {...rest}>
103
- <ReplyForm
104
- isPending={isPending}
105
- onCancel={onCancel}
106
- onChange={onChange}
107
- onSubmit={onSubmit}
108
- value={value}
109
- />
110
- </PopupBase>
106
+ <FocusTrap>
107
+ <PopupBase
108
+ ref={popupRef}
109
+ aria-label={intl.formatMessage(messages.ariaLabelComment)}
110
+ data-resin-component="popupReply"
111
+ options={popupOptions.current}
112
+ role="dialog"
113
+ {...rest}
114
+ >
115
+ <ReplyForm
116
+ isPending={isPending}
117
+ onCancel={onCancel}
118
+ onChange={onChange}
119
+ onSubmit={onSubmit}
120
+ value={value}
121
+ />
122
+ </PopupBase>
123
+ </FocusTrap>
111
124
  );
112
125
  }
@@ -1,6 +1,11 @@
1
1
  import { defineMessages } from 'react-intl';
2
2
 
3
3
  export default defineMessages({
4
+ ariaLabelComment: {
5
+ id: 'ba.popup.reply.comment',
6
+ description: 'Aria label description for reply popup',
7
+ defaultMessage: 'Comment',
8
+ },
4
9
  buttonCancel: {
5
10
  id: 'ba.popups.cancel',
6
11
  description: 'Button label for cancelling the creation of a description, comment, or reply',
@@ -204,6 +204,7 @@ export default class ReplyField extends React.Component<Props, State> {
204
204
  <div className={classnames(className, 'ba-ReplyField')}>
205
205
  <Editor
206
206
  {...rest}
207
+ ariaMultiline
207
208
  editorState={editorState}
208
209
  handleReturn={this.handleReturn}
209
210
  onChange={this.handleChange}
@@ -212,6 +213,7 @@ export default class ReplyField extends React.Component<Props, State> {
212
213
  placeholder={placeholder}
213
214
  readOnly={isDisabled}
214
215
  stripPastedStyles
216
+ tabIndex={0}
215
217
  webDriverTestID="ba-ReplyField-editor"
216
218
  />
217
219
 
@@ -60,14 +60,20 @@ export default class DocumentAnnotator extends BaseAnnotator {
60
60
  const pageReferenceEl = this.getPageReference(pageEl);
61
61
  const managers = this.managers.get(pageNumber) || new Set();
62
62
  const resinTags = { fileid: fileId, iscurrent: isCurrentFileVersion };
63
+ let destroyManagers = false;
63
64
 
64
- // Destroy any managers that were attached to page elements that no longer exist
65
+ // If a referenced page element doesn't exist, destroy all managers to keep them in sync
65
66
  managers.forEach(manager => {
66
67
  if (!manager.exists(pageEl)) {
67
- manager.destroy();
68
- managers.delete(manager);
68
+ destroyManagers = true;
69
69
  }
70
70
  });
71
+ if (destroyManagers) {
72
+ managers.forEach(manager => {
73
+ manager.destroy();
74
+ });
75
+ managers.clear();
76
+ }
71
77
 
72
78
  // Lazily instantiate managers as pages are added or re-rendered
73
79
  if (managers.size === 0) {
@@ -15,6 +15,6 @@
15
15
  // transform applied to each of the managers' react mount element to account for
16
16
  // rotation
17
17
  .ba-Layer--popup {
18
- z-index: 1;
18
+ z-index: 4;
19
19
  }
20
20
  }