-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MR Permissions - Group and Project dropdown issues #3219
Changes from all commits
cb89299
3eed1aa
8e4b63f
257acc6
6058971
645d361
016f481
186b5df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,6 @@ export interface TypeaheadSelectProps extends Omit<SelectProps, 'toggle' | 'onSe | |
|
||
const defaultNoOptionsFoundMessage = (filter: string) => `No results found for "${filter}"`; | ||
const defaultCreateOptionMessage = (newValue: string) => `Create "${newValue}"`; | ||
|
||
const defaultFilterFunction = (filterValue: string, options: TypeaheadSelectOption[]) => | ||
options.filter((o) => String(o.content).toLowerCase().includes(filterValue.toLowerCase())); | ||
|
||
|
@@ -212,12 +211,10 @@ const TypeaheadSelect: React.FunctionComponent<TypeaheadSelectProps> = ({ | |
const onInputClick = () => { | ||
if (!isOpen) { | ||
openMenu(); | ||
setTimeout(() => { | ||
textInputRef.current?.focus(); | ||
}, 100); | ||
} else if (isFiltering) { | ||
closeMenu(); | ||
} | ||
setTimeout(() => { | ||
textInputRef.current?.focus(); | ||
}, 100); | ||
}; | ||
|
||
const selectOption = ( | ||
|
@@ -401,6 +398,7 @@ const TypeaheadSelect: React.FunctionComponent<TypeaheadSelectProps> = ({ | |
onSelect={handleSelect} | ||
onOpenChange={(open) => !open && closeMenu()} | ||
toggle={toggle} | ||
shouldFocusFirstItemOnOpen={false} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added as suggested from Jeff |
||
ref={innerRef} | ||
{...props} | ||
> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,11 +51,10 @@ const RoleBindingPermissionsNameInput: React.FC<RoleBindingPermissionsNameInputP | |
const displayName = isProjectSubject ? namespaceToProjectDisplayName(option, projects) : option; | ||
return { value: displayName, content: displayName }; | ||
}); | ||
|
||
if (value && !typeAhead.includes(value)) { | ||
// If we've selected an option that doesn't exist via isCreatable, include it in the options so it remains selected | ||
if (value && !selectOptions.some((option) => option.value === value)) { | ||
selectOptions.push({ value, content: value }); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the code that was adding the current value to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah fair point, I guess removing this entirely solves that as well |
||
return ( | ||
<TypeaheadSelect | ||
selectOptions={selectOptions} | ||
|
@@ -68,6 +67,7 @@ const RoleBindingPermissionsNameInput: React.FC<RoleBindingPermissionsNameInputP | |
} | ||
}} | ||
placeholder={placeholderText} | ||
createOptionMessage={(newValue) => `Select "${newValue}"`} | ||
/> | ||
); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems reasonable to me and does fix the focus issue, but I'm curious if @jeff-phillips-18 has an opinion on it since he wrote this code in #3094.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this, I would say it is ok to remove the timeout, but in the
<Select>
component below, add parameter:This will keep focus on the input when the user clicks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeff-phillips-18 what about the removal of the
closeMenu()
call here? I don't think I'm seeing the menu close when clicking the input anyway, I wonder if that's getting counteracted in the existing code. I don't see a problem with this part of the diff as-is, just wanted to make sure.