@atlaskit/react-select 1.5.0 → 1.5.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/react-select
2
2
 
3
+ ## 1.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#167291](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/167291)
8
+ [`4645a4d115b15`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4645a4d115b15) -
9
+ Fix the calculation of scroll space below to place menu bottom as much as possible
10
+
11
+ ## 1.5.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#174296](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/174296)
16
+ [`b9f79083be192`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b9f79083be192) -
17
+ Adding extra semantics to listbox
18
+
3
19
  ## 1.5.0
4
20
 
5
21
  ### Minor Changes
@@ -16,6 +16,7 @@ var _react2 = require("@emotion/react");
16
16
  var _dom = require("@floating-ui/dom");
17
17
  var _reactDom = require("react-dom");
18
18
  var _useIsomorphicLayoutEffect = _interopRequireDefault(require("use-isomorphic-layout-effect"));
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
20
  var _utils = require("../utils");
20
21
  var _excluded = ["children", "innerProps"],
21
22
  _excluded2 = ["children", "innerProps"];
@@ -53,7 +54,8 @@ function getMenuPlacement(_ref) {
53
54
  // we can't trust `scrollParent.scrollHeight` --> it may increase when
54
55
  // the menu is rendered
55
56
  var _scrollParent$getBoun = scrollParent.getBoundingClientRect(),
56
- scrollHeight = _scrollParent$getBoun.height;
57
+ scrollHeight = _scrollParent$getBoun.height,
58
+ scrollParentTop = _scrollParent$getBoun.top;
57
59
  var _menuEl$getBoundingCl = menuEl.getBoundingClientRect(),
58
60
  menuBottom = _menuEl$getBoundingCl.bottom,
59
61
  menuHeight = _menuEl$getBoundingCl.height,
@@ -62,12 +64,14 @@ function getMenuPlacement(_ref) {
62
64
  containerTop = _menuEl$offsetParent$.top;
63
65
  var viewHeight = isFixedPosition ? window.innerHeight : (0, _utils.normalizedHeight)(scrollParent);
64
66
  var scrollTop = (0, _utils.getScrollTop)(scrollParent);
67
+ // use menuTop - scrollParentTop for the actual top space of menu in the scroll container
68
+ var menuTopFromParent = (0, _platformFeatureFlags.fg)('design-system-select-fix-placement') ? menuTop - scrollParentTop : menuTop;
65
69
  var marginBottom = parseInt(getComputedStyle(menuEl).marginBottom, 10);
66
70
  var marginTop = parseInt(getComputedStyle(menuEl).marginTop, 10);
67
71
  var viewSpaceAbove = containerTop - marginTop;
68
- var viewSpaceBelow = viewHeight - menuTop;
72
+ var viewSpaceBelow = viewHeight - menuTopFromParent;
69
73
  var scrollSpaceAbove = viewSpaceAbove + scrollTop;
70
- var scrollSpaceBelow = scrollHeight - scrollTop - menuTop;
74
+ var scrollSpaceBelow = scrollHeight - scrollTop - menuTopFromParent;
71
75
  var scrollDown = menuBottom - viewHeight + scrollTop + marginBottom;
72
76
  var scrollUp = scrollTop + menuTop - marginTop;
73
77
  var scrollDuration = 160;
@@ -1641,6 +1641,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1641
1641
  onBottomArrive: onMenuScrollToBottom,
1642
1642
  lockEnabled: menuShouldBlockScroll
1643
1643
  }, function (scrollTargetRef) {
1644
+ var _this4$inputRef;
1644
1645
  return /*#__PURE__*/_react.default.createElement(MenuList, (0, _extends2.default)({}, commonProps, {
1645
1646
  innerRef: function innerRef(instance) {
1646
1647
  _this4.getMenuListRef(instance);
@@ -1652,7 +1653,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1652
1653
  id: _this4.getElementId('listbox')
1653
1654
  }, (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') && {
1654
1655
  'aria-label': label,
1655
- 'aria-labelledby': "".concat(labelId || _this4.getElementId('input'), " ").concat(commonProps.isMulti && (0, _helpers.isSafari)() ? _this4.getElementId('multi-message') : '')
1656
+ 'aria-labelledby': "".concat(labelId || ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input'), " ").concat(commonProps.isMulti && (0, _helpers.isSafari)() ? _this4.getElementId('multi-message') : '')
1656
1657
  }),
1657
1658
  isLoading: isLoading,
1658
1659
  maxHeight: maxHeight,
@@ -8,6 +8,7 @@ import { jsx } from '@emotion/react';
8
8
  import { autoUpdate } from '@floating-ui/dom';
9
9
  import { createPortal } from 'react-dom';
10
10
  import useLayoutEffect from 'use-isomorphic-layout-effect';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { animatedScrollTo, getBoundingClientObj, getScrollParent, getScrollTop, getStyleProps, normalizedHeight, scrollTo } from '../utils';
12
13
 
13
14
  // ==============================
@@ -40,7 +41,8 @@ export function getMenuPlacement({
40
41
  // we can't trust `scrollParent.scrollHeight` --> it may increase when
41
42
  // the menu is rendered
42
43
  const {
43
- height: scrollHeight
44
+ height: scrollHeight,
45
+ top: scrollParentTop
44
46
  } = scrollParent.getBoundingClientRect();
45
47
  const {
46
48
  bottom: menuBottom,
@@ -52,12 +54,14 @@ export function getMenuPlacement({
52
54
  } = menuEl.offsetParent.getBoundingClientRect();
53
55
  const viewHeight = isFixedPosition ? window.innerHeight : normalizedHeight(scrollParent);
54
56
  const scrollTop = getScrollTop(scrollParent);
57
+ // use menuTop - scrollParentTop for the actual top space of menu in the scroll container
58
+ const menuTopFromParent = fg('design-system-select-fix-placement') ? menuTop - scrollParentTop : menuTop;
55
59
  const marginBottom = parseInt(getComputedStyle(menuEl).marginBottom, 10);
56
60
  const marginTop = parseInt(getComputedStyle(menuEl).marginTop, 10);
57
61
  const viewSpaceAbove = containerTop - marginTop;
58
- const viewSpaceBelow = viewHeight - menuTop;
62
+ const viewSpaceBelow = viewHeight - menuTopFromParent;
59
63
  const scrollSpaceAbove = viewSpaceAbove + scrollTop;
60
- const scrollSpaceBelow = scrollHeight - scrollTop - menuTop;
64
+ const scrollSpaceBelow = scrollHeight - scrollTop - menuTopFromParent;
61
65
  const scrollDown = menuBottom - viewHeight + scrollTop + marginBottom;
62
66
  const scrollUp = scrollTop + menuTop - marginTop;
63
67
  const scrollDuration = 160;
@@ -1670,25 +1670,28 @@ export default class Select extends Component {
1670
1670
  onTopArrive: onMenuScrollToTop,
1671
1671
  onBottomArrive: onMenuScrollToBottom,
1672
1672
  lockEnabled: menuShouldBlockScroll
1673
- }, scrollTargetRef => /*#__PURE__*/React.createElement(MenuList, _extends({}, commonProps, {
1674
- innerRef: instance => {
1675
- this.getMenuListRef(instance);
1676
- scrollTargetRef(instance);
1677
- },
1678
- innerProps: {
1679
- role: 'listbox',
1680
- 'aria-multiselectable': (this.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
1681
- id: this.getElementId('listbox'),
1682
- // add aditional label on listbox when ff is on
1683
- ...(fg('design_system_select-a11y-improvement') && {
1684
- 'aria-label': label,
1685
- 'aria-labelledby': `${labelId || this.getElementId('input')} ${commonProps.isMulti && isSafari() ? this.getElementId('multi-message') : ''}`
1686
- })
1687
- },
1688
- isLoading: isLoading,
1689
- maxHeight: maxHeight,
1690
- focusedOption: focusedOption
1691
- }), menuUI))));
1673
+ }, scrollTargetRef => {
1674
+ var _this$inputRef;
1675
+ return /*#__PURE__*/React.createElement(MenuList, _extends({}, commonProps, {
1676
+ innerRef: instance => {
1677
+ this.getMenuListRef(instance);
1678
+ scrollTargetRef(instance);
1679
+ },
1680
+ innerProps: {
1681
+ role: 'listbox',
1682
+ 'aria-multiselectable': (this.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
1683
+ id: this.getElementId('listbox'),
1684
+ // add aditional label on listbox when ff is on
1685
+ ...(fg('design_system_select-a11y-improvement') && {
1686
+ 'aria-label': label,
1687
+ 'aria-labelledby': `${labelId || ((_this$inputRef = this.inputRef) === null || _this$inputRef === void 0 ? void 0 : _this$inputRef.id) || this.getElementId('input')} ${commonProps.isMulti && isSafari() ? this.getElementId('multi-message') : ''}`
1688
+ })
1689
+ },
1690
+ isLoading: isLoading,
1691
+ maxHeight: maxHeight,
1692
+ focusedOption: focusedOption
1693
+ }), menuUI);
1694
+ })));
1692
1695
 
1693
1696
  // positioning behaviour is almost identical for portalled and fixed,
1694
1697
  // so we use the same component. the actual portalling logic is forked
@@ -15,6 +15,7 @@ import { jsx } from '@emotion/react';
15
15
  import { autoUpdate } from '@floating-ui/dom';
16
16
  import { createPortal } from 'react-dom';
17
17
  import useLayoutEffect from 'use-isomorphic-layout-effect';
18
+ import { fg } from '@atlaskit/platform-feature-flags';
18
19
  import { animatedScrollTo, getBoundingClientObj, getScrollParent, getScrollTop, getStyleProps, normalizedHeight, scrollTo } from '../utils';
19
20
 
20
21
  // ==============================
@@ -46,7 +47,8 @@ export function getMenuPlacement(_ref) {
46
47
  // we can't trust `scrollParent.scrollHeight` --> it may increase when
47
48
  // the menu is rendered
48
49
  var _scrollParent$getBoun = scrollParent.getBoundingClientRect(),
49
- scrollHeight = _scrollParent$getBoun.height;
50
+ scrollHeight = _scrollParent$getBoun.height,
51
+ scrollParentTop = _scrollParent$getBoun.top;
50
52
  var _menuEl$getBoundingCl = menuEl.getBoundingClientRect(),
51
53
  menuBottom = _menuEl$getBoundingCl.bottom,
52
54
  menuHeight = _menuEl$getBoundingCl.height,
@@ -55,12 +57,14 @@ export function getMenuPlacement(_ref) {
55
57
  containerTop = _menuEl$offsetParent$.top;
56
58
  var viewHeight = isFixedPosition ? window.innerHeight : normalizedHeight(scrollParent);
57
59
  var scrollTop = getScrollTop(scrollParent);
60
+ // use menuTop - scrollParentTop for the actual top space of menu in the scroll container
61
+ var menuTopFromParent = fg('design-system-select-fix-placement') ? menuTop - scrollParentTop : menuTop;
58
62
  var marginBottom = parseInt(getComputedStyle(menuEl).marginBottom, 10);
59
63
  var marginTop = parseInt(getComputedStyle(menuEl).marginTop, 10);
60
64
  var viewSpaceAbove = containerTop - marginTop;
61
- var viewSpaceBelow = viewHeight - menuTop;
65
+ var viewSpaceBelow = viewHeight - menuTopFromParent;
62
66
  var scrollSpaceAbove = viewSpaceAbove + scrollTop;
63
- var scrollSpaceBelow = scrollHeight - scrollTop - menuTop;
67
+ var scrollSpaceBelow = scrollHeight - scrollTop - menuTopFromParent;
64
68
  var scrollDown = menuBottom - viewHeight + scrollTop + marginBottom;
65
69
  var scrollUp = scrollTop + menuTop - marginTop;
66
70
  var scrollDuration = 160;
@@ -1632,6 +1632,7 @@ var Select = /*#__PURE__*/function (_Component) {
1632
1632
  onBottomArrive: onMenuScrollToBottom,
1633
1633
  lockEnabled: menuShouldBlockScroll
1634
1634
  }, function (scrollTargetRef) {
1635
+ var _this4$inputRef;
1635
1636
  return /*#__PURE__*/React.createElement(MenuList, _extends({}, commonProps, {
1636
1637
  innerRef: function innerRef(instance) {
1637
1638
  _this4.getMenuListRef(instance);
@@ -1643,7 +1644,7 @@ var Select = /*#__PURE__*/function (_Component) {
1643
1644
  id: _this4.getElementId('listbox')
1644
1645
  }, fg('design_system_select-a11y-improvement') && {
1645
1646
  'aria-label': label,
1646
- 'aria-labelledby': "".concat(labelId || _this4.getElementId('input'), " ").concat(commonProps.isMulti && isSafari() ? _this4.getElementId('multi-message') : '')
1647
+ 'aria-labelledby': "".concat(labelId || ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input'), " ").concat(commonProps.isMulti && isSafari() ? _this4.getElementId('multi-message') : '')
1647
1648
  }),
1648
1649
  isLoading: isLoading,
1649
1650
  maxHeight: maxHeight,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-select",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "A forked version of react-select to only be used in atlaskit/select",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -63,6 +63,9 @@
63
63
  },
64
64
  "platform_design_system_team_safari_input_fix": {
65
65
  "type": "boolean"
66
+ },
67
+ "design-system-select-fix-placement": {
68
+ "type": "boolean"
66
69
  }
67
70
  },
68
71
  "techstack": {