UI: fix blank selection on search select field (#15058)

* WIP

* Cleanup

* cleanup

* Add changelog
This commit is contained in:
Chelsea Shaw 2022-04-15 12:47:55 -05:00 committed by GitHub
parent 774bf2241a
commit d43324831b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 8 deletions

3
changelog/15058.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: fix search-select component showing blank selections when editing group member entity
```

View File

@ -26,6 +26,15 @@
This README outlines the details of collaborating on this Ember application. This README outlines the details of collaborating on this Ember application.
## Ember CLI Version Matrix
| Vault Version | Ember Version |
| ------------- | ------------- |
| 1.10.x | 3.28.5 |
| 1.9.x | 3.22.0 |
| 1.8.x | 3.22.0 |
| 1.7.x | 3.11 |
## Prerequisites ## Prerequisites
You will need the following things properly installed on your computer. You will need the following things properly installed on your computer.
@ -117,8 +126,8 @@ To run the tests locally in a browser other than IE11, swap out `launch_in_ci: [
### Linting ### Linting
* `yarn lint` - `yarn lint`
* `yarn lint:fix` - `yarn lint:fix`
### Building Vault UI into a Vault Binary ### Building Vault UI into a Vault Binary
@ -185,7 +194,8 @@ Note that placing a param inside brackets (e.g. `[closedLabel=More options]` ind
3. Inside the newly generated `stories` file, add at least one example of the component. If the component should be interactive, enable the [Storybook Knobs addon](https://github.com/storybooks/storybook/tree/master/addons/knobs). 3. Inside the newly generated `stories` file, add at least one example of the component. If the component should be interactive, enable the [Storybook Knobs addon](https://github.com/storybooks/storybook/tree/master/addons/knobs).
4. Generate the `notes` file for the component with `yarn gen-story-md [name-of-component] [name-of-engine-or-addon]` (e.g. `yarn gen-md alert-banner core`). This will generate markdown documentation of the component and place it at `vault/ui/stories/[name-of-component].md`. If your component is a template-only component, you will need to manually create the markdown file. The markdown file will need to be imported in your `[component-name].stories.js` file (e.g. `import notes from './[name-of-component].md'`). 4. Generate the `notes` file for the component with `yarn gen-story-md [name-of-component] [name-of-engine-or-addon]` (e.g. `yarn gen-md alert-banner core`). This will generate markdown documentation of the component and place it at `vault/ui/stories/[name-of-component].md`. If your component is a template-only component, you will need to manually create the markdown file. The markdown file will need to be imported in your `[component-name].stories.js` file (e.g. `import notes from './[name-of-component].md'`).
5. The completed `[component-name].stories.js` file should look something like this (with knobs): 5. The completed `[component-name].stories.js` file should look something like this (with knobs):
````js
```js
import hbs from 'htmlbars-inline-precompile'; import hbs from 'htmlbars-inline-precompile';
import { storiesOf } from '@storybook/ember'; import { storiesOf } from '@storybook/ember';
import { text, withKnobs } from '@storybook/addon-knobs'; import { text, withKnobs } from '@storybook/addon-knobs';
@ -203,12 +213,12 @@ storiesOf('MyComponent', module)
`, `,
context: { context: {
param: text('param', 'My parameter'), param: text('param', 'My parameter'),
anotherParam: boolean('anotherParam', true) anotherParam: boolean('anotherParam', true),
}, },
}), }),
{ notes } { notes }
); );
```` ```
See the [Storybook Docs](https://storybook.js.org/docs/basics/introduction/) for more information on writing stories. See the [Storybook Docs](https://storybook.js.org/docs/basics/introduction/) for more information on writing stories.

View File

@ -87,6 +87,7 @@ export default Component.extend({
searchText: matchingOption ? matchingOption.searchText : option, searchText: matchingOption ? matchingOption.searchText : option,
}; };
}); });
this.set('selectedOptions', formattedOptions); this.set('selectedOptions', formattedOptions);
if (this.options) { if (this.options) {
options = this.options.concat(options).uniq(); options = this.options.concat(options).uniq();
@ -113,7 +114,13 @@ export default Component.extend({
this.formatOptions(options); this.formatOptions(options);
} catch (err) { } catch (err) {
if (err.httpStatus === 404) { if (err.httpStatus === 404) {
//leave options alone, it's okay if (!this.options) {
// If the call failed but the resource has items
// from a different namespace, this allows the
// selected items to display
this.set('options', []);
}
return; return;
} }
if (err.httpStatus === 403) { if (err.httpStatus === 403) {