@jetbrains/ring-ui 6.0.55 → 6.0.57

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.
@@ -137,7 +137,10 @@ export default class Auth {
137
137
  this.addListener(LOGOUT_EVENT, this.config.onLogout);
138
138
  }
139
139
  if (this.config.reloadOnUserChange) {
140
- this.addListener(USER_CHANGED_EVENT, () => this._reloadCurrentPage());
140
+ this.addListener(USER_CHANGED_EVENT, () => {
141
+ // Timeout is needed to ensure all other listeners triggered before stopping current page
142
+ setTimeout(() => this._reloadCurrentPage());
143
+ });
141
144
  }
142
145
  this.addListener(LOGOUT_POSTPONED_EVENT, () => this._setPostponed(true));
143
146
  this.addListener(USER_CHANGE_POSTPONED_EVENT, () => this._setPostponed(true));
@@ -21,6 +21,7 @@ export interface DialogProps extends Partial<TabTrapProps> {
21
21
  dense?: boolean | null | undefined;
22
22
  native?: boolean;
23
23
  modal?: boolean;
24
+ preventBodyScroll?: boolean;
24
25
  }
25
26
  export default class Dialog extends PureComponent<DialogProps> {
26
27
  static propTypes: {
@@ -41,6 +42,7 @@ export default class Dialog extends PureComponent<DialogProps> {
41
42
  portalTarget: PropTypes.Requireable<HTMLElement>;
42
43
  autoFocusFirst: PropTypes.Requireable<boolean>;
43
44
  'data-test': PropTypes.Requireable<string>;
45
+ preventBodyScroll: PropTypes.Requireable<boolean>;
44
46
  };
45
47
  static defaultProps: Partial<DialogProps>;
46
48
  state: {
@@ -41,7 +41,8 @@ export default class Dialog extends PureComponent {
41
41
  trapFocus: PropTypes.bool,
42
42
  portalTarget: PropTypes.instanceOf(HTMLElement),
43
43
  autoFocusFirst: PropTypes.bool,
44
- 'data-test': PropTypes.string
44
+ 'data-test': PropTypes.string,
45
+ preventBodyScroll: PropTypes.bool
45
46
  };
46
47
  static defaultProps = {
47
48
  label: 'Dialog',
@@ -54,7 +55,8 @@ export default class Dialog extends PureComponent {
54
55
  shortcutOptions: { modal: false },
55
56
  trapFocus: false,
56
57
  autoFocusFirst: true,
57
- modal: true
58
+ modal: true,
59
+ preventBodyScroll: true
58
60
  };
59
61
  state = {
60
62
  shortcutsScope: getUID('ring-dialog-')
@@ -93,6 +95,9 @@ export default class Dialog extends PureComponent {
93
95
  }
94
96
  }
95
97
  toggleScrollPreventer() {
98
+ if (!this.props.preventBodyScroll) {
99
+ return;
100
+ }
96
101
  if (this.props.show) {
97
102
  this.scrollPreventer.prevent();
98
103
  }
@@ -125,7 +130,7 @@ export default class Dialog extends PureComponent {
125
130
  };
126
131
  nativeDialog = createRef();
127
132
  render() {
128
- const { show, showCloseButton, onOverlayClick, onCloseAttempt, onEscPress, onCloseClick, children, className, contentClassName, trapFocus, 'data-test': dataTest, closeButtonInside, portalTarget, label, closeButtonTitle, dense, shortcutOptions, native, modal, ...restProps } = this.props;
133
+ const { show, showCloseButton, onOverlayClick, onCloseAttempt, onEscPress, onCloseClick, children, className, contentClassName, trapFocus, 'data-test': dataTest, closeButtonInside, portalTarget, label, closeButtonTitle, dense, shortcutOptions, native, modal, preventBodyScroll, ...restProps } = this.props;
129
134
  const classes = classNames(styles.container, className);
130
135
  const shortcutsMap = this.getShortcutsMap();
131
136
  const content = (<>
@@ -213,6 +213,9 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
213
213
  shortcutsScope: string;
214
214
  listId: string;
215
215
  private _focusHandler;
216
+ isClickingSelect: boolean;
217
+ mouseDownHandler: () => void;
218
+ mouseUpHandler: () => void;
216
219
  private _blurHandler;
217
220
  node?: HTMLElement | null;
218
221
  nodeRef: (el: HTMLElement | null) => void;
@@ -315,9 +315,17 @@ export default class Select extends Component {
315
315
  focused: true
316
316
  });
317
317
  };
318
+ isClickingSelect = false;
319
+ mouseDownHandler = () => {
320
+ this.isClickingSelect = true;
321
+ };
322
+ mouseUpHandler = () => {
323
+ this.isClickingSelect = false;
324
+ };
318
325
  _blurHandler = () => {
319
326
  this.props.onBlur();
320
- if (this._popup && this._popup.isVisible() && !this._popup.isClickingPopup) {
327
+ if (this._popup && this._popup.isVisible() && !this._popup.isClickingPopup &&
328
+ !this.isClickingSelect) {
321
329
  window.setTimeout(() => {
322
330
  this.setState({ showPopup: false });
323
331
  });
@@ -822,7 +830,8 @@ export default class Select extends Component {
822
830
  switch (this.props.type) {
823
831
  case Type.INPUT_WITHOUT_CONTROLS:
824
832
  case Type.INPUT: return (<>
825
- <div ref={this.nodeRef} className={classNames(classes, styles.inputMode)} data-test={dataTests('ring-select', dataTest)}>
833
+ <div ref={this.nodeRef} className={classNames(classes, styles.inputMode)} data-test={dataTests('ring-select', dataTest)} role="presentation" // has interactive elements inside
834
+ onMouseDown={this.mouseDownHandler} onMouseUp={this.mouseUpHandler}>
826
835
  {shortcutsEnabled && (<Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>)}
827
836
  <Input {...ariaProps} height={this.props.height} autoComplete="off" id={this.props.id} onClick={this._clickHandler} inputRef={this.composedFilterRef(this.filterRef, this.props.filterRef)} disabled={this.props.disabled} value={this.state.filterValue} borderless={this.props.type === Type.INPUT_WITHOUT_CONTROLS} style={style} size={Size.FULL} onChange={this._filterChangeHandler} onFocus={this._focusHandler} onBlur={this._blurHandler}
828
837
  // Input with error style without description
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "6.0.55",
3
+ "version": "6.0.57",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",