Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Roles] ComboBox overflow fix (elastic#184722)
## Summary Fixed `ComboBox` overflow with large chips. Applies to the following fields: - Indices. - Remote indices. - Remote clusters. <img width="1242" alt="Screenshot 2024-06-04 at 11 43 39" src="https://github.com/elastic/kibana/assets/165678770/ee6dc3e3-0c6b-449b-85a7-7d82acb51b8e"> https://github.com/elastic/kibana/assets/165678770/f6bbc325-a957-4c3e-bc88-721b77dc8ff0 Options considered: 1. **Flex with specific grow attribute set**. This will not stop the `ComboBox` from growing after it reaches 50% point of available space. ``` <EuiFlexGroup> <EuiFlexItem grow={5}>...</EuiFlexItem> <EuiFlexItem grow={5}>...</EuiFlexItem> </EuiFlexGroup> ``` 2. **Grid with columns.** ``` <EuiFlexGrid columns={2}> <EuiFlexItem>...</EuiFlexItem> <EuiFlexItem>...</EuiFlexItem> </EuiFlexGrid> ``` CSS is the following. ``` grid-template-columns: repeat(2, 1fr); ``` The problem is that `1fr` is about the distribution of available space, as soon as content of `ComboBox` becomes bigger it breaks. 3. **Combobox props.** We have `fullWidth` attribute set that we need for stretching to available column space, so the content doesn't wrap unless there is the `maxWidth` set for column. Alternative is to remove `fullWidth` which wraps chips correctly, but then doesn't satisfy the design. 4. **`maxWidth` for `EuiFlexItem`.** ``` <EuiFlexGroup> <EuiFlexItem style={{ maxWidth: '50%' }}>...</EuiFlexItem> <EuiFlexItem style={{ maxWidth: '50%' }}>...</EuiFlexItem> </EuiFlexGroup> ``` That option works, but since we have the same form for index privileges and remote index privileges, we would need to justify it for 2 columns (maxWidth: '50%' ), 3 columns (maxWidth: '33%' ) and mobile accordingly (maxWidth: '100%' ). Can be less scalable. 4. Leverage grid `minmax`. ``` grid-template-columns: repeat(N, minmax(0, 1fr)); ``` It allows to create columns as large as `1fr` and not exceed it, so `ComboBox` will nicely fit. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) __Fixes: https://github.com/elastic/kibana/issues/183311__ ### Release note Fixed `ComboBox` overflow with large chips. --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information