Skip to content

Conversation

@CamsCampos
Copy link

@CamsCampos CamsCampos commented Aug 11, 2021

Visualização mobile do novo componente:

image

Comment on lines +40 to +42
if (isFunction(afterChange)) {
afterChange(v);
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaoassisb e @nerissa-aguirre, uma sugestão de vcs era usar a lógica do handleOnChangeFactory que vem do useFormControl para executar o afterChange, no entanto, a implementação atual de handleOnChangeFactory requer um evento. Como esse novo componente não emite um evento ao mudar, recebo um erro ao tentar usar ohandleOnChangeFactory. Uma maneira seria adaptar o handleOnChangeFactory pra lidar com esse caso, mas por enquanto achei mais simples deixar assim, que é a forma como está implementado no componente <FormAutocomplete/> também

image

@CamsCampos CamsCampos marked this pull request as ready for review August 16, 2021 19:23
CamsCampos and others added 5 commits August 19, 2021 16:14
Co-authored-by: nerissa-aguirre <79877143+nerissa-aguirre@users.noreply.github.com>
<div ref={dropdownRef}>
<Dropdown
isOpen={isOpen}
items={includeEmptyItem ? [{ value: null, label: <div className="m-3"></div> }, ...items] : items}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essa <div className="m-3" /> é para que o label vazio tenha um largura maior.

Comment on lines 99 to 112
export function getSelectedOption(value, options, trackBy) {
if (!trackBy) {
return options.find((option) => option.value === value);
}

return options.find((option) => getValueByPath(option.value, trackBy) === getValueByPath(value, trackBy));
}

export function getSelectedValue(value, options, trackBy) {
let selectedValue = value;

if (trackBy) {
const selectedOption = options.find(
(option) => getValueByPath(option.value, trackBy) === getValueByPath(value, trackBy)
);
const selectedOption = getSelectedOption(value, options, trackBy);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alterei o nome da antiga função getSelectedOption para getSelectedValue (que é o que de fato a função retorna) para poder criar uma função getSelectedOption que retorna a option completa pra usar no <FormDropdown />

@nerissa-aguirre nerissa-aguirre merged commit 60fae42 into master Aug 25, 2021
@nerissa-aguirre nerissa-aguirre deleted the feat-novo-componente-dropdown-select branch August 25, 2021 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants