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

Record selector bug fixes and UX improvements #1856

Merged
merged 82 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
8165a56
Improve naming of property
seancolsen Oct 19, 2022
ae252b9
Improve record selector window title
seancolsen Oct 19, 2022
db687f9
Use a button instead of the ghost row
seancolsen Oct 19, 2022
72251f9
Improve grammar in record selector window title
seancolsen Oct 19, 2022
850d2e4
Switch some code between RS table and results
seancolsen Oct 19, 2022
4b45c56
Show parent results while nested selector is open
seancolsen Oct 20, 2022
fa31706
Don't allow focusing UI inside LinkedRecordInput
seancolsen Oct 20, 2022
a891bd3
Clean up code in RecordSelectorInput
seancolsen Oct 20, 2022
9cf509b
Improve component name
seancolsen Oct 20, 2022
8553595
Combine Record Selector table and results
seancolsen Oct 20, 2022
e6bebd2
Fix handleKeydown when nested selector is open
seancolsen Oct 20, 2022
182d2cf
Move some code from table to content component
seancolsen Oct 20, 2022
13c4156
Clean up some type code
seancolsen Oct 20, 2022
834b3e6
Remove unused CSS class
seancolsen Oct 20, 2022
552326c
Begin converting record selector markup to table
seancolsen Oct 21, 2022
b5c8f31
Improve vertical scroll behavior of table
seancolsen Oct 21, 2022
c330b36
Improve horizontal scrolling in table
seancolsen Oct 21, 2022
451eeb1
Rename component
seancolsen Oct 22, 2022
63337c5
Style submit button and row selection
seancolsen Oct 24, 2022
2adcfd1
Merge branch 'master' into record_selector_ux
seancolsen Oct 25, 2022
bd75484
Fix duplication initialization loading spinner
seancolsen Oct 25, 2022
30724e4
Add padding to column header cells
seancolsen Oct 25, 2022
20f9b1e
Remove dropdown arrow in disabled LinkedRecordCell
seancolsen Oct 25, 2022
3ea5639
Don't render special PK cells in record selector
seancolsen Oct 25, 2022
384c91d
Improve input row aesthetics
seancolsen Oct 25, 2022
4633ac0
Sort imports
seancolsen Oct 25, 2022
d316d4a
Show focus indicator on input cell
seancolsen Oct 25, 2022
4c4328e
Improve shadows
seancolsen Oct 26, 2022
8ad64d7
Make minor adjustments to nested selector style
seancolsen Oct 26, 2022
6aab805
Don't cut off horizontal edges of focus indicator
seancolsen Oct 26, 2022
c94aec3
Display cell component even while loading
seancolsen Oct 26, 2022
da50af2
Merge branch 'master' into record_selector_ux
seancolsen Oct 26, 2022
36d01bb
Don't have a selected record while loading records
seancolsen Oct 26, 2022
0e29c1c
Fix inconsistent label in LinkedRecord.svelte
seancolsen Oct 26, 2022
26f0dca
Allow LinkedRecordCell to make its column wider
seancolsen Oct 26, 2022
8abb889
Refactor DataCell into its own component
seancolsen Oct 26, 2022
708b839
Show tooltip on truncated data cells
seancolsen Oct 26, 2022
5f6d9df
Close record selector after navigation
seancolsen Oct 26, 2022
3511a7d
Remove space between LinkedRecord pill & dropdown
seancolsen Oct 26, 2022
c9742cd
Match style between row button & new record button
seancolsen Oct 26, 2022
2f1b33c
Don't highlight row when hover new record button
seancolsen Oct 26, 2022
de3d1f2
Close nested selector on Esc
seancolsen Oct 26, 2022
1d092db
Hyperlink to table page from window title
seancolsen Oct 26, 2022
64339e8
Don't open nested selector on clear FK input value
seancolsen Oct 26, 2022
84181b9
Disable hyperlinks in FK search input cells
seancolsen Oct 26, 2022
61dcafa
Fix incorrect class
seancolsen Oct 27, 2022
48a7566
Highlight matching text in text cells
seancolsen Oct 27, 2022
d200b26
Merge branch 'master' into record_selector_ux
seancolsen Oct 28, 2022
fad8582
Fix import order
seancolsen Oct 28, 2022
d750c40
Merge branch 'master' into record_selector_ux
seancolsen Oct 28, 2022
25ea373
Eliminate superfluous records request
seancolsen Oct 28, 2022
e2be596
Be smart about which column to focus initially
seancolsen Oct 28, 2022
730083e
Focus LinkedRecordInput after RecordSelector close
seancolsen Oct 28, 2022
4f5b935
Close record selector when click on link in title
seancolsen Oct 28, 2022
74e48b5
Improve type assertion
seancolsen Oct 28, 2022
84711e5
Don't close filters UI on click in record selector
seancolsen Oct 29, 2022
d067649
Remove unused component
seancolsen Oct 30, 2022
201205a
Refactor all z-index to follow code standards
seancolsen Oct 30, 2022
b8d892a
Don't let FK columns shrink when table shrinks
seancolsen Nov 1, 2022
90efb12
Allow FK input to push column wider
seancolsen Nov 1, 2022
fb1f56f
Allow NULL option in boolean input
seancolsen Nov 1, 2022
bfb1b6c
Forward focus/blur events for Select
seancolsen Nov 1, 2022
2b0d771
Make Select component dispatch standard events
seancolsen Nov 1, 2022
7052a35
Make boolean input look like other inputs
seancolsen Nov 1, 2022
5a91bcc
Consolidate some CSS
seancolsen Nov 1, 2022
131261a
Dispatch standard events from DateTimeInput
seancolsen Nov 1, 2022
1da0d17
Allow negative numbers in NumberInput
seancolsen Nov 1, 2022
addf73c
Fix casing mismatch
seancolsen Nov 2, 2022
2591f18
Highlight search matches in TextBoxCell
seancolsen Nov 2, 2022
a3c5232
Highlight search matches in UriCell
seancolsen Nov 2, 2022
41a1a37
Allow column header to push column wider
seancolsen Nov 3, 2022
0a1d556
Merge branch 'master' into record_selector_ux
seancolsen Nov 3, 2022
c88ae41
Clean up some overridden CSS
seancolsen Nov 3, 2022
f60b7c4
Fix column header cell to with content-box sizing
seancolsen Nov 3, 2022
95616f6
Show record creation errors in toast message
seancolsen Nov 3, 2022
91cdb0e
Fix regexp to work in Safari
seancolsen Nov 3, 2022
faa268f
Merge branch 'master' into record_selector_ux
seancolsen Nov 3, 2022
4ece0dc
Prevent focusing a data row hyperlink
seancolsen Nov 3, 2022
39fa5a0
Merge branch 'master' into record_selector_ux
pavish Nov 10, 2022
e4a159d
Fix chips in array cell consuming full cell width
seancolsen Nov 10, 2022
4f01720
Clean up accompanying dropdown element
seancolsen Nov 10, 2022
562caa4
Merge branch 'master' into record_selector_ux
pavish Nov 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions mathesar_ui/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<script lang="ts">
import { ToastPresenter, Confirmation } from '@mathesar-component-library';
import { toast } from '@mathesar/stores/toast';
import { setNewRecordSelectorControllerInContext } from '@mathesar/systems/record-selector/RecordSelectorController';
import {
RecordSelectorController,
setRecordSelectorControllerInContext,
} from '@mathesar/systems/record-selector/RecordSelectorController';
import { confirmationController } from '@mathesar/stores/confirmation';
import { modal } from './stores/modal';
import ModalRecordSelector from './systems/record-selector/ModalRecordSelector.svelte';
import RootRoute from './routes/RootRoute.svelte';

const recordSelectorModal = modal.spawnModalController();
const recordSelectorController = setNewRecordSelectorControllerInContext({
const recordSelectorController = new RecordSelectorController({
onOpen: () => recordSelectorModal.open(),
onClose: () => recordSelectorModal.close(),
nestingLevel: 0,
});
setRecordSelectorControllerInContext(recordSelectorController);
</script>

<ToastPresenter entries={toast.entries} />
Expand Down Expand Up @@ -96,8 +100,6 @@
--border-radius-s: 0.142rem; //2px
--border-radius-m: 0.285rem; //4px
--border-radius-l: 0.571rem; //8px
--modal-z-index: 50;
--modal-record-selector-z-index: 50;
}

body {
Expand Down Expand Up @@ -145,6 +147,11 @@
--header-height: 4.285rem;

color: var(--slate-400);

--modal-z-index: 1;
--dropdown-z-index: 1;
--cell-errors-z-index: 1;
--toast-z-index: 2;
}

h1 {
Expand All @@ -166,6 +173,7 @@
font-size: inherit;
font-weight: inherit;
text-align: inherit;
text-decoration: inherit;
margin: 0;
padding: 0;
}
Expand Down
14 changes: 9 additions & 5 deletions mathesar_ui/src/component-library/button/Button.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
button.btn {
.btn {
display: inline-flex;
align-items: center;
vertical-align: middle;
Expand Down Expand Up @@ -39,7 +39,8 @@ button.btn {
color: var(--white);

&:not(:disabled) {
&:hover {
&:hover,
&.hover {
background: var(--brand-600);
border-color: var(--brand-600);
}
Expand All @@ -56,7 +57,8 @@ button.btn {
border-color: var(--slate-100);

&:not(:disabled) {
&:hover {
&:hover,
&.hover {
background: var(--slate-300);
border-color: var(--slate-300);
}
Expand Down Expand Up @@ -85,12 +87,14 @@ button.btn {
&.btn-default,
&.btn-plain {
&:not(:disabled) {
&:hover {
&:hover,
&.hover {
background: #f3f4f5;
}

&:active,
&:focus {
&:focus,
&.focus {
box-shadow: 0 0 0 2px #2087e633 !important;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
display: -ms-flexbox;
display: flex;
position: relative;
isolation: isolate;
}
.flatpickr-months .flatpickr-month {
background: transparent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ export class AccompanyingElements implements Readable<Set<HTMLElement>> {
this.parent = parent;
}

add(el: HTMLElement): void {
/**
* @returns a function to remove the element, which should be called to avoid
* memory leaks
*/
add(el: HTMLElement): () => void {
this.elements.update((elements) => {
const s = new Set(elements);
s.add(el);
return s;
});
this.parent?.add(el);
return () => this.delete(el);
}

delete(el: HTMLElement): void {
Expand Down
2 changes: 1 addition & 1 deletion mathesar_ui/src/component-library/dropdown/Dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ button.dropdown.trigger {
rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;
border-radius: var(--border-radius-l);
background: #fff;
z-index: 100;
z-index: var(--dropdown-z-index, 100);
max-height: calc(100vh - 5em);
overflow: auto;

Expand Down
1 change: 1 addition & 0 deletions mathesar_ui/src/component-library/dropdown/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as Dropdown } from './Dropdown.svelte';
export { default as AttachableDropdown } from './AttachableDropdown.svelte';
export * from './AccompanyingElements';
4 changes: 2 additions & 2 deletions mathesar_ui/src/component-library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export { default as Help } from './help/Help.svelte';
export { default as Icon } from './icon/Icon.svelte';
export { InputGroup, InputGroupText } from './input-group';
export { default as LabeledInput } from './labeled-input/LabeledInput.svelte';
export { default as MatchHighlighter } from './match-highlighter/MatchHighlighter.svelte';
export {
NumberInput,
StringifiedNumberInput,
Expand All @@ -43,7 +42,6 @@ export { default as TextInput } from './text-input/TextInput.svelte';
export { default as TextInputWithPrefix } from './text-input/TextInputWithPrefix.svelte';

// Compound Components (Ordered)
export { AttachableDropdown, Dropdown } from './dropdown';
export { DatePicker, InlineDateTimePicker } from './date-time-picker';
export { default as DropdownMenu } from './dropdown-menu/DropdownMenu.svelte';
export { default as DataTypeBasedInput } from './data-type-based-input/DataTypeBasedInput.svelte';
Expand All @@ -60,6 +58,8 @@ export { default as Window } from './window/Window.svelte';
// Systems
export * from './label';
export * from './confirmation';
export * from './dropdown';
export * from './match-highlighter';
export * from './menu';
export * from './modal';
export * from './toast';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
display: flex;
flex-wrap: nowrap;
align-items: stretch;
isolation: isolate;

.input-group-text {
display: flex;
Expand All @@ -24,7 +25,7 @@
.input-element,
button {
&:focus {
z-index: 10;
z-index: 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
<script lang="ts">
import { splitMatchParts } from './matchHighlighterUtils';
import Match from './Match.svelte';
import type Match from './Match.svelte';
import PrecomputedMatchHighlighter from './PrecomputedMatchHighlighter.svelte';

export let text: string;
export let substring = '';
export let matchComponent = Match;
export let matchComponent: typeof Match | undefined = undefined;

$: matchParts = splitMatchParts(text, substring);
</script>

<span class="match-highlighter">
{#each matchParts as part}
{#if part.isMatch}
<svelte:component this={matchComponent}>{part.text}</svelte:component>
{:else}
{part.text}
{/if}
{/each}
</span>
<PrecomputedMatchHighlighter {matchParts} {matchComponent} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts">
import Match from './Match.svelte';
import type { MatchPart } from './matchHighlighterTypes';

export let matchParts: MatchPart[];
export let matchComponent: typeof Match | undefined = undefined;

/**
* This line is only necessary because I couldn't figure out how to appease
* TypeScript with the `matchComponent` prop.
*/
$: match = matchComponent ?? Match;
</script>

<span class="match-highlighter">
{#each matchParts as part}
{#if part.isMatch}
<svelte:component this={match}>{part.text}</svelte:component>
{:else}
{part.text}
{/if}
{/each}
</span>
6 changes: 6 additions & 0 deletions mathesar_ui/src/component-library/match-highlighter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { default as MatchHighlighter } from './MatchHighlighter.svelte';
export { default as PrecomputedMatchHighlighter } from './PrecomputedMatchHighlighter.svelte';
export {
splitMatchParts,
getValueComparisonOutcome,
} from './matchHighlighterUtils';
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ export interface MatchPart {
text: string;
isMatch: boolean;
}

export type ValueComparisonOutcome =
| 'exactMatch'
| 'substringMatch'
| 'noMatch';
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { toAsciiLowerCase } from '@mathesar-component-library-dir/common/utils';
import type { MatchPart } from './matchHighlighterTypes';
import type {
MatchPart,
ValueComparisonOutcome,
} from './matchHighlighterTypes';

export function match(text: string): MatchPart {
return { text, isMatch: true };
Expand Down Expand Up @@ -38,3 +41,15 @@ export function splitMatchParts(text: string, substring: string): MatchPart[] {
}
return matchParts;
}

export function getValueComparisonOutcome(
matchParts: MatchPart[],
): ValueComparisonOutcome | undefined {
if (matchParts.length === 0) {
return undefined;
}
if (matchParts.length === 1) {
return matchParts[0].isMatch ? 'exactMatch' : 'noMatch';
}
return 'substringMatch';
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.notification {
display: flex;
flex-direction: column;
z-index: 10;

&.danger {
background: #393939;
Expand Down
12 changes: 11 additions & 1 deletion mathesar_ui/src/component-library/select/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
type $$Props = SelectProps<Option>;
type DefinedProps = Required<$$Props>;

const dispatch = createEventDispatcher<{ change: Option | undefined }>();
const dispatch = createEventDispatcher<{
change: Option | undefined;
input: Option | undefined;
artificialChange: Option | undefined;
artificialInput: Option | undefined;
}>();

export let id: DefinedProps['id'] = getGloballyUniqueId();
export let disabled: DefinedProps['disabled'] = false;
Expand Down Expand Up @@ -79,6 +84,9 @@
function setValueFromArray(values: (Option | undefined)[]) {
[value] = values;
dispatch('change', value);
dispatch('input', value);
dispatch('artificialChange', value);
dispatch('artificialInput', value);
}

function setValueOnOptionChange(opts: Option[]) {
Expand Down Expand Up @@ -144,6 +152,8 @@
on:open={() => api.open()}
on:close={() => api.close()}
on:keydown={(e) => api.handleKeyDown(e)}
on:focus
on:blur
>
<svelte:fragment slot="trigger">
{#if $$slots.default}
Expand Down
2 changes: 2 additions & 0 deletions mathesar_ui/src/component-library/tabs/TabContainer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
align-items: center;
display: flex;
position: relative;
isolation: isolate;
flex-direction: row;
margin: 0;
padding: 0;
Expand Down Expand Up @@ -93,5 +94,6 @@
border-top: none;
border-radius: 0px 0px 2px 2px;
position: relative;
isolation: isolate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
margin: 0;
padding: 0;
list-style-type: none;
z-index: 9999;
z-index: var(--toast-z-index, 999);
}
1 change: 1 addition & 0 deletions mathesar_ui/src/component-library/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './text-area/TextAreaTypes';
export * from './select/SelectTypes';
export * from './number-input/NumberInputTypes';
export * from './date-time-picker/DateTimePickerTypes';
export * from './match-highlighter/matchHighlighterTypes';
10 changes: 9 additions & 1 deletion mathesar_ui/src/component-library/window/Window.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
display: grid;
grid-template: auto 1fr auto / auto;
box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.3);
position: relative;
isolation: isolate;

.title-bar {
grid-row: 1;
Expand All @@ -33,9 +35,15 @@
background: #f3f6f8;
}

> .body,
&.has-body-padding > .body {
padding: 1em;
}
> .footer {
padding: 1em;
}

> .body,
> .footer {
overflow: hidden;
&:empty {
display: none;
Expand Down
7 changes: 6 additions & 1 deletion mathesar_ui/src/component-library/window/Window.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
export let title: string | undefined = undefined;
export let hasCloseButton = true;
export let canScrollBody = true;
export let hasBodyPadding = true;

function handleCloseButtonClick() {
dispatch('close');
}
</script>

<div class="window" class:can-scroll-body={canScrollBody}>
<div
class="window"
class:can-scroll-body={canScrollBody}
class:has-body-padding={hasBodyPadding}
>
{#if $$slots.title || title || hasCloseButton}
<div class="title-bar">
<div class="title">
Expand Down
Loading