您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

react-focus-lock-wrapper.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. // @flow
  2. import React from 'react';
  3. import FocusLock, { MoveFocusInside } from 'react-focus-lock';
  4. /**
  5. * FocusLock wrapper that disable the FocusLock in the @atlaskit/modal-dialog. We need to disable it because if the
  6. * iframe API is used and a dialog is displayed it is impossible to click on fields outside of the iframe (FocusLock
  7. * will steal the focus from any element that is not part of the dialog).
  8. */
  9. export default class FocusLockWrapper extends FocusLock<*> {
  10. /**
  11. * Implements React's {@link Component#render()}.
  12. *
  13. * @inheritdoc
  14. * @returns {ReactElement}
  15. */
  16. render() {
  17. const { children, ...otherProps } = this.props;
  18. const props = {
  19. ...otherProps,
  20. crossFrame: false
  21. };
  22. // MoveFocusInside is added in order to initially bring the focus on the dialog.
  23. return (
  24. <FocusLock
  25. { ...props }
  26. className = 'focus-lock'>
  27. <MoveFocusInside>{children}</MoveFocusInside>
  28. </FocusLock>
  29. );
  30. }
  31. }
  32. export * from 'react-focus-lock';