Skip to content
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

Table: Datepicker, AutoComplete, Select Cell Editor #2387

Merged
merged 39 commits into from
Jun 7, 2024

Conversation

ElishaSamPeterPrabhu
Copy link
Collaborator

@ElishaSamPeterPrabhu ElishaSamPeterPrabhu commented Apr 1, 2024

Description

  • Updated dropdown, autocomplete to accept badge and links args and datepicker of cell to handle out of focus

References

#2310 , #2311 , #2313

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

https://deploy-preview-2387--moduswebcomponents.netlify.app/

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@ElishaSamPeterPrabhu ElishaSamPeterPrabhu changed the title Update focus of datepicker Table: Datepicker Cell Editor Apr 1, 2024
Copy link

netlify bot commented Apr 1, 2024

Deploy Preview for moduswebcomponents ready!

Name Link
🔨 Latest commit 317ece5
🔍 Latest deploy log https://app.netlify.com/sites/moduswebcomponents/deploys/6662bb1ffd55eb0008e711cb
😎 Deploy Preview https://deploy-preview-2387--moduswebcomponents.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 24 (no change from production)
Accessibility: 98 (no change from production)
Best Practices: 92 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@coliff coliff requested a review from cjwinsor April 2, 2024 09:36
@ElishaSamPeterPrabhu ElishaSamPeterPrabhu changed the title Table: Datepicker Cell Editor Table: Datepicker,AutoComplete,Select Cell Editor Apr 4, 2024
@cjwinsor
Copy link
Contributor

cjwinsor commented Apr 25, 2024

@ElishaSamPeterPrabhu Some observations:
Storybook:

  • Autocomplete should have all First Names from Names array
  • Autocomplete for the last row will have its items require the user to scroll down in the container to see
  • CreatedAt should be of type Date so we can show that too
  • Email column's Autocomplete options should contain all emails

Component:

  • Autocomplete should set the value
  • Autocomplete should show items on focus
  • Autocomplete, you can't use arrows or tab to navigate the items in the list, table handling takes over. (arrows work for number)
  • Autocomplete increases the row height
  • Date should set value
  • Date column and editor formatting should match
  • Date doesn't lose focus when you click away
  • Date Calendar is inside the overflow container, any way to pop it out? Last item you can look at

@coliff coliff changed the title Table: Datepicker,AutoComplete,Select Cell Editor Table: Datepicker, AutoComplete, Select Cell Editor Apr 30, 2024
@cjwinsor
Copy link
Contributor

cjwinsor commented Jun 3, 2024

@ElishaSamPeterPrabhu I went over these changes again and this is what I think is needed before we can merge:

  • Remove the overflow: auto from .table-container in modus-table.scss. Instead modus-table.tsx should set overflow: auto only when a maxHeight is provided. This way, if no maxHeight is defined then the datepicker and autocomplete won't be hidden inside the overflow container. It doesn't fix for when maxHeight is defined, but at gives a workaround until we can address this.
  • Switch from using "dropdown" for the Select component. Use "select" instead. Update all code to match. This is to avoid confusion with our drop down component we have already which is different.
  • Don't reuse ModusTableCellDropdownEditorArgs for Autocomplete, create a new type for it.
  • ModusTableCellDropdownEditorArgs should have optionsDisplayProp as well, in addition to options.
  • The ModusTableCellAutocompleteEditorArgs which you'll have created above, should have the following additional properties (beyond just options): noResultsFoundText, noResultsFoundSubtext, showNoResultsFoundMessage, showOptionsOnFocus.
  • ModusTableCellAutocompleteEditorArgs.options should be of type ModusAutocompleteOption
  • For autocomplete, it seems if i click on the cell in the whitepace, then click on another cell, it loses focus correctly, but if i click on the text then another cell it doesn't loose focus. Might be related to the example being a link, I didn't check with a non link autocomplete column
  • I think we need to make sure ModusTableCellEditorType in storybook and code shows and supports all the different cell editor types, it currently only shows type ModusTableCellEditorType = typeof CELL_EDIT_TYPE_DROPDOWN;

@ElishaSamPeterPrabhu
Copy link
Collaborator Author

@ElishaSamPeterPrabhu I went over these changes again and this is what I think is needed before we can merge:

  • Remove the overflow: auto from .table-container in modus-table.scss. Instead modus-table.tsx should set overflow: auto only when a maxHeight is provided. This way, if no maxHeight is defined then the datepicker and autocomplete won't be hidden inside the overflow container. It doesn't fix for when maxHeight is defined, but at gives a workaround until we can address this.
  • Switch from using "dropdown" for the Select component. Use "select" instead. Update all code to match. This is to avoid confusion with our drop down component we have already which is different.
  • Don't reuse ModusTableCellDropdownEditorArgs for Autocomplete, create a new type for it.
  • ModusTableCellDropdownEditorArgs should have optionsDisplayProp as well, in addition to options.
  • The ModusTableCellAutocompleteEditorArgs which you'll have created above, should have the following additional properties (beyond just options): noResultsFoundText, noResultsFoundSubtext, showNoResultsFoundMessage, showOptionsOnFocus.
  • ModusTableCellAutocompleteEditorArgs.options should be of type ModusAutocompleteOption
  • For autocomplete, it seems if i click on the cell in the whitepace, then click on another cell, it loses focus correctly, but if i click on the text then another cell it doesn't loose focus. Might be related to the example being a link, I didn't check with a non link autocomplete column
  • I think we need to make sure ModusTableCellEditorType in storybook and code shows and supports all the different cell editor types, it currently only shows type ModusTableCellEditorType = typeof CELL_EDIT_TYPE_DROPDOWN;

Have worked on all of the above suggestions
Regarding the autocomplete focus behavior its seems to be working fine :

Components._.Table.-.Inline.Editing.Storybook.-.Google.Chrome.2024-06-05.11-19-16.mp4

@@ -86,6 +86,10 @@ import { createGuid } from '../../utils/utils';
export class ModusTable {
@Element() element: HTMLElement;

@Prop() editableCellId: string[] = [];
@Watch('editableCellId') onEditableCellIdsChange(newVal: string[]) {
console.log('editableCellIds', newVal);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove console.log, and was this editableCellId prop only used for debugging? If so, remove, otherwise we will need to discuss its purpose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops committed it by mistake, will remove it

@@ -373,6 +377,7 @@ export class ModusTable {
this.setTableState(initialTableState);
this.onRowsExpandableChange(this.rowsExpandable);
this.initializeTable();
console.log('editableCellId232s', this.editableCellId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove console.log

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

@@ -25,28 +26,40 @@ import { ModusAutocompleteOption } from '../../../../modus-autocomplete/modus-au
})
export class ModusTableCellEditor {
@Prop() args: ModusTableCellEditorArgs;
@Prop() value: string;
@Prop() dataType: string;
@Prop() value: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use any, if we can't establish the type then use unknown

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced with unknown

@Prop() type: string;
@Prop() valueChange: (newValue: string) => void;
@Prop() keyDown: (e: KeyboardEvent, newValue: string) => void;

private editedValue: string;
private editedValue: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use any, if we can't establish the type then use unknown

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced with unknown

private inputElement: HTMLElement;
private outsideClickListener: (event: any) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this be of type MouseEvent

Copy link
Collaborator Author

@ElishaSamPeterPrabhu ElishaSamPeterPrabhu Jun 7, 2024

Choose a reason for hiding this comment

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

Yes, changed

};
if (this.type == 'date') document.addEventListener('click', this.outsideClickListener);
}
disconnectedCallback(): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ultimately if we use the @Listen then we won't need to have this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced the callback logic with listen

const args = this.args as ModusTableCellSelectEditorArgs;
const options = args?.options || [];
const optionsDisplayProp = args?.optionsDisplayProp || valueKey;
const selectedOption = options.find((option) => option[optionsDisplayProp] === this.value) as any;
Copy link
Contributor

Choose a reason for hiding this comment

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

Type would be unknown. Always be mindful of these lint errors and correct when they are seen. Avoid using any even when prototyping.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced with unknown

size="large"
options={options}
onInputBlur={this.handleBlur}
onKeyDown={(e) => handleEnter(e, this.handleKeyDown)}
onValueChange={(e: CustomEvent<unknown>) => {
this.editedValue = e.detail[valueKey];
if (this.dataType === 'badge') {
const { display, ...restProps } = e.detail as any;
Copy link
Contributor

Choose a reason for hiding this comment

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

any should be unknown

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced with unknown

const options = ((this.args as ModusTableCellDropdownEditorArgs)?.options || []) as ModusAutocompleteOption[] | string[];
let options, selectedOption;
const args = this.args as ModusTableCellAutocompleteEditorArgs;
// const { noResultsFoundText, noResultsFoundSubtext, showNoResultsFoundMessage, showOptionsOnFocus } = args;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented out code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

{...this.getDefaultProps('Autocomplete input')}
include-search-icon="false"
size="medium"
//onClick={(e: MouseEvent) => e.stopPropagation()}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented out code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

@ElishaSamPeterPrabhu
Copy link
Collaborator Author

ElishaSamPeterPrabhu commented Jun 7, 2024

For the autocomplete focus issue:
Added this.cell.focus() when a link is clicked instead of the white space this handles the out of focus issue as expected
PS: The link issue of autocomplete was present in the badge type as well when clicking on the badge directly instead of the whitespace, so added the same logic to badge as well.

@cjwinsor cjwinsor merged commit c53b4bc into main Jun 7, 2024
11 checks passed
@cjwinsor cjwinsor deleted the issue-2310/table-date-cell-picker branch June 7, 2024 22:14
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.

2 participants