Skip to content

Commit

Permalink
create overlay for bubble text field suggestions, #2949
Browse files Browse the repository at this point in the history
  • Loading branch information
vaf-hub committed Apr 27, 2021
1 parent a745c12 commit bd60868
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/calendar/view/CalendarEventEditDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ export function showCalendarEventDialog(date: Date, calendars: Map<Id, CalendarI
renderChangesMessage(),
m(".mb", m(ExpanderPanelN, {
expanded: attendeesExpanded,
overflowVisible: true // TODO get rid of this?
},
[
m(".flex-grow", renderInvitationField()),
Expand Down Expand Up @@ -534,7 +535,7 @@ function makeBubbleTextField(viewModel: CalendarEventViewModel, contactModel: Co
},
}, contactModel)

const invitePeopleValueTextField = new BubbleTextField("addGuest_label", bubbleHandler, {marginLeft: 0})
const invitePeopleValueTextField = new BubbleTextField("addGuest_label", bubbleHandler)
invitePeopleValueTextField.textField._injectionsRight = () => renderConfidentialButton(viewModel)
return invitePeopleValueTextField
}
Expand Down
7 changes: 2 additions & 5 deletions src/gui/base/BubbleTextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export class BubbleTextField<T> {

_domSuggestions: HTMLElement;

constructor(labelIdOrLabelTextFunction: TranslationKey | lazy<string>, bubbleHandler: BubbleHandler<T, any>,
suggestionStyle: {[string]: any} = {}) {
constructor(labelIdOrLabelTextFunction: TranslationKey | lazy<string>, bubbleHandler: BubbleHandler<T, any>) {
this.loading = null
this.suggestions = []
this.selectedSuggestion = null
Expand Down Expand Up @@ -106,7 +105,6 @@ export class BubbleTextField<T> {
this.textField._keyHandler = key => this.handleKey(key)

this.bubbleHandler = bubbleHandler

this.view = () => {
return m('.bubble-text-field', [
m(this.textField, {
Expand All @@ -123,10 +121,9 @@ export class BubbleTextField<T> {
})
}
}),
m(".suggestions.text-ellipsis.ml-negative-l", {
m(`.suggestions-overlay.text-ellipsis${this.suggestions.length ? ".dropdown-shadow" : ""}`, {
oncreate: vnode => this._domSuggestions = vnode.dom,
onmousedown: e => this.textField.skipNextBlur = true,
style: suggestionStyle,
}, this.suggestions.map(s => m(s, {
mouseDownHandler: e => {
this.selectedSuggestion = s
Expand Down
4 changes: 3 additions & 1 deletion src/gui/base/Expander.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type ExpanderAttrs = {

export type ExpanderPanelAttrs = {
expanded: Stream<boolean>,
overflowVisible?: boolean,
}

export class ExpanderButtonN implements MComponent<ExpanderAttrs> {
Expand Down Expand Up @@ -110,7 +111,8 @@ export class ExpanderPanelN implements MComponent<ExpanderPanelAttrs> {
: 0
// The expander panel children are wrapped in an extra div so that we can calculate the height properly,
// since offsetHeight doesn't include borders or margins
return m(".expander-panel.overflow-hidden",
// by default we hide overflow
return m(`.expander-panel${vnode.attrs.overflowVisible ? "" : ".overflow-hidden"}`,
m("div", {
style: {
opacity: expanded() ? "1" : "0",
Expand Down
9 changes: 9 additions & 0 deletions src/gui/main-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,15 @@ styles.registerStyle('main', () => {
'margin-top': requiresStatusBarHack() ? "20px" : 'env(safe-area-inset-top)' // insets for iPhone X)
},

'.bubble-text-field': {'position': 'relative'},
'.suggestions-overlay': {
'z-index': '999',
'position': "absolute",
'width': '100%',
'box-shadow': boxShadow,
'background-color': theme.elevated_bg
},

'bottom-nav': {
'box-shadow': `0 -2px 4px 0 ${theme.header_box_shadow_bg}`,
height: positionValue(size.bottom_nav_bar),
Expand Down

0 comments on commit bd60868

Please sign in to comment.